From owner-freebsd-firewire@FreeBSD.ORG Mon Aug 25 11:06:49 2008 Return-Path: Delivered-To: freebsd-firewire@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BF32D1065686 for ; Mon, 25 Aug 2008 11:06:49 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A6E9F8FC16 for ; Mon, 25 Aug 2008 11:06:49 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m7PB6nRE027733 for ; Mon, 25 Aug 2008 11:06:49 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m7PB6ng2027729 for freebsd-firewire@FreeBSD.org; Mon, 25 Aug 2008 11:06:49 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 25 Aug 2008 11:06:49 GMT Message-Id: <200808251106.m7PB6ng2027729@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-firewire@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-firewire@FreeBSD.org X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Aug 2008 11:06:49 -0000 Current FreeBSD problem reports Critical problems Serious problems S Tracker Resp. Description -------------------------------------------------------------------------------- o kern/74238 firewire [firewire] fw_rcv: unknown response; firewire ad-hoc w 1 problem total. Non-critical problems S Tracker Resp. Description -------------------------------------------------------------------------------- o kern/113785 firewire [firewire] dropouts when playing DV on firewire 1 problem total. From owner-freebsd-firewire@FreeBSD.ORG Wed Aug 27 00:33:40 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF31A106564A for ; Wed, 27 Aug 2008 00:33:40 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 1D47A8FC0A for ; Wed, 27 Aug 2008 00:33:39 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7R0X8O75434; Tue, 26 Aug 2008 17:33:08 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id AAA13884; Wed, 27 Aug 2008 00:31:46 GMT Message-Id: <200808270031.AAA13884@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Thu, 21 Aug 2008 19:12:16 PDT." <48AE2080.7050409@miralink.com> Date: Tue, 26 Aug 2008 17:31:46 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Aug 2008 00:33:41 -0000 > >> Can you run a live linux distro(unbuntu or knoppix) and see if linux can > >> "reset" > >> your NEC f/w controller? What does penguinix call firewire? (none):~ # dmesg | grep -i fire (none):~ # dmesg | grep -i fw (none):~ # dmesg | grep -i 1394 (none):~ # dmesg | grep -i link audit: initializing netlink socket (disabled) eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] Split[0] WireSpeed[1] TSOcap[1] (none):~ # man -k fire fire: nothing appropriate. (none):~ # man -k fw fw: nothing appropriate. (none):~ # man -k 1394 1394: nothing appropriate. (none):~ # man -k link link: nothing appropriate. Anyway, due to a firmware bug I ended up having to power cycle the machine. (switched off at the P/S, so even 5V standby should have been off) I was expecting the power cycle to completely reset the NEC board. But it is not back to normal. I no longer get the spewage from a constant series of bus resets, but fwcontrol -R still doesn't work. fwcontrol_prev is from March, and used to do -R successfully. fwcontrol_prev -R /dv0/test_prev_camera.dv Detected DV format on input. (EAGAIN) (EAGAIN) (EAGAIN) fwcontrol_prev -u 1 -p === base register === 0x00 0x85 0xe2 0x42 0xd7 0x03 0x00 0x00 Physical_ID:0 R:0 CPS:0 RHB:1 IBR:0 Gap_Count:5 Extended:7 Num_Ports:2 PHY_Speed:2 Delay:2 LCtrl:1 C:1 Jitter:2 Pwr_Class:7 WDIE:0 ISBR:0 CTOI:0 CPSI:0 STOI:0 PEI:0 EAA:1 EMC:1 Max_Legacy_SPD:0 BLINK:0 Bridge:0 Page_Select:0 Port_Select0 === page 0 port 0 === 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Astat:0 BStat:0 Ch:1 Con:0 RXOK:0 Dis:0 Negotiated_speed:0 PIE:0 Fault:0 Stanby_fault:0 Disscrm:0 B_Only:0 DC_connected:0 Max_port_speed:0 LPP:0 Cable_speed:0 Connection_unreliable:0 Beta_mode:0 Port_error:0x0 Loop_disable:0 In_standby:0 Hard_disable:0 === page 0 port 1 === 0xf6 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Astat:3 BStat:3 Ch:0 Con:1 RXOK:1 Dis:0 Negotiated_speed:0 PIE:0 Fault:0 Stanby_fault:0 Disscrm:0 B_Only:0 DC_connected:0 Max_port_speed:0 LPP:0 Cable_speed:0 Connection_unreliable:0 Beta_mode:0 Port_error:0x0 Loop_disable:0 In_standby:0 Hard_disable:0 === page 1 === 0x01 0x00 0x00 0x00 0x4c 0x02 0x00 0x00 Compliance:1 Vendor_ID:0x00004c Product_ID:0x020000 fwcontrol_prev -u 1 -t crc_len: 4 generation:6 node_count:2 sid_count:2 id link gap_cnt speed delay cIRM power port0 port1 port2 ini more 00 1 5 S400 0 1 -9W - P 1 0 01 1 5 S100 0 1 0W - C 0 0 Now what? From owner-freebsd-firewire@FreeBSD.ORG Wed Aug 27 03:03:40 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 230571065676 for ; Wed, 27 Aug 2008 03:03:40 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id D248A8FC19 for ; Wed, 27 Aug 2008 03:03:39 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 5BCA61A917E; Tue, 26 Aug 2008 19:54:25 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bNYthq367tvK; Tue, 26 Aug 2008 19:54:24 -0700 (PDT) Received: from [10.47.1.6] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id AF2011A917B; Tue, 26 Aug 2008 19:54:24 -0700 (PDT) Message-ID: <48B4C407.9010900@miralink.com> Date: Tue, 26 Aug 2008 20:03:35 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808270031.AAA13884@sopwith.solgatos.com> In-Reply-To: <200808270031.AAA13884@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Aug 2008 03:03:40 -0000 Dieter wrote: >>>> Can you run a live linux distro(unbuntu or knoppix) and see if linux can >>>> "reset" >>>> your NEC f/w controller? >>>> > > What does penguinix call firewire? > > (none):~ # dmesg | grep -i fire > (none):~ # dmesg | grep -i fw > (none):~ # dmesg | grep -i 1394 > (none):~ # dmesg | grep -i link > audit: initializing netlink socket (disabled) > eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] Split[0] WireSpeed[1] TSOcap[1] > > (none):~ # man -k fire > fire: nothing appropriate. > (none):~ # man -k fw > fw: nothing appropriate. > (none):~ # man -k 1394 > 1394: nothing appropriate. > (none):~ # man -k link > link: nothing appropriate. > > I was hoping that you could boot linux, and then plugin your camera and see what the output of dmesg and /var/log/messages has to say. > Anyway, due to a firmware bug I ended up having to power cycle > the machine. (switched off at the P/S, so even 5V standby should > have been off) > > I was expecting the power cycle to completely reset the NEC board. > But it is not back to normal. I no longer get the spewage from a > constant series of bus resets, but fwcontrol -R still doesn't work. > > fwcontrol_prev is from March, and used to do -R successfully. > > fwcontrol_prev -R /dv0/test_prev_camera.dv > Detected DV format on input. > (EAGAIN) > (EAGAIN) > (EAGAIN) > > Is there any chance that you overwrote fwcontrol_prev with my patched version? Could you pull fwcontrol from src and recompile just to check? -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Cell 503-358-6832 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com From owner-freebsd-firewire@FreeBSD.ORG Wed Aug 27 05:46:58 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC89D1065680 for ; Wed, 27 Aug 2008 05:46:58 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id EACBC8FC15 for ; Wed, 27 Aug 2008 05:46:56 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7R5fbD75867; Tue, 26 Aug 2008 22:41:37 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id FAA16991; Wed, 27 Aug 2008 05:40:45 GMT Message-Id: <200808270540.FAA16991@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Tue, 26 Aug 2008 20:03:35 PDT." <48B4C407.9010900@miralink.com> Date: Tue, 26 Aug 2008 22:40:45 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: Something broke :-( Re: fwcontrol update X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Aug 2008 05:46:58 -0000 > > What does penguinix call firewire? > > > > (none):~ # dmesg | grep -i fire > > (none):~ # dmesg | grep -i fw > > (none):~ # dmesg | grep -i 1394 > > (none):~ # dmesg | grep -i link > > audit: initializing netlink socket (disabled) > > eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] Split[0] WireSpeed[1] TSOcap[1] > > > > (none):~ # man -k fire > > fire: nothing appropriate. > > (none):~ # man -k fw > > fw: nothing appropriate. > > (none):~ # man -k 1394 > > 1394: nothing appropriate. > > (none):~ # man -k link > > link: nothing appropriate. > > > > > I was hoping that you could boot linux, and then plugin your camera and > see what the output of dmesg and /var/log/messages has to say. Shouldn't linux print something in dmesg about the controllers? Shouldn't there be man pages? But who cares? See below. > > Anyway, due to a firmware bug I ended up having to power cycle > > the machine. (switched off at the P/S, so even 5V standby should > > have been off) > > > > I was expecting the power cycle to completely reset the NEC board. > > But it is not back to normal. I no longer get the spewage from a > > constant series of bus resets, but fwcontrol -R still doesn't work. > > > > fwcontrol_prev is from March, and used to do -R successfully. > > > > fwcontrol_prev -R /dv0/test_prev_camera.dv > > Detected DV format on input. > > (EAGAIN) > > (EAGAIN) > > (EAGAIN) > > > > > Is there any chance that you overwrote fwcontrol_prev with my patched > version? No. The modification date is March 5th, which is when the very useful -f option was added. This version was used successfully used with -R before I tried the recent modifications. Today's mistake was forgetting to include the "-u 1", so it was looking for DV from the VIA controller. With -u 1 it is working fine. So the power cycle *did* fix it. Whew! So why does fwcontrol print "Detected DV format on input." when there isn't even a device plugged into the bus? Very misleading! From owner-freebsd-firewire@FreeBSD.ORG Thu Aug 28 23:14:35 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 050F91065691 for ; Thu, 28 Aug 2008 23:14:35 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 4DCD58FC0A for ; Thu, 28 Aug 2008 23:14:33 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7SNEQ580567; Thu, 28 Aug 2008 16:14:26 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id XAA17597; Thu, 28 Aug 2008 23:13:29 GMT Message-Id: <200808282313.XAA17597@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Mon, 11 Aug 2008 18:07:03 PDT." <48A0E237.5020702@miralink.com> Date: Thu, 28 Aug 2008 16:13:29 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: This is where I'm going with fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Aug 2008 23:14:35 -0000 While looking at the code and wondering what "adjust_gap_count" had to do with cyclemaster mode, I noticed that -f was setting the 2nd argument to send_phy_config(int fd, int root_node, int gap_count) which is root_node, not gap_count. I also noticed that send_phy_config() does (root_node & 0x3f), so having the range check be 0x3f rather than INT32_MAX seems to make sense. I haven't yet figured out exactly which 7 bits this stuff is actually setting. So does the following look like an improvement (however minor) to anyone else, or just me? :-) @@ -730,7 +730,7 @@ bool dump_phy_reg = false; int32_t priority_budget = -1; - int32_t adjust_gap_count = -1; + int32_t set_root_node = -1; int32_t reset_gap_count = -1; int32_t send_link_on = -1; int32_t send_reset_start = -1; @@ -790,9 +790,9 @@ display_board_only = false; break; case 'f': - adjust_gap_count = strtol(optarg, NULL, 0); - if ( (adjust_gap_count < 0) || (adjust_gap_count > INT32_MAX) ) - err(EX_USAGE, "%s:adjust_gap_count out of range", __func__); + set_root_node = strtol(optarg, NULL, 0); + if ( (set_root_node < 0) || (set_root_node > 0x3f) ) + err(EX_USAGE, "%s:set_root_node out of range", __func__); open_needed = true; command_set = true; display_board_only = false; @@ -961,8 +961,8 @@ /* * Adjust the gap count for this card/bus to value "-f" */ - if (adjust_gap_count >= 0) - send_phy_config(fd, adjust_gap_count, -1); + if (set_root_node >= 0) + send_phy_config(fd, set_root_node, -1); /* * Reset the gap count for this card/bus "-g" From owner-freebsd-firewire@FreeBSD.ORG Thu Aug 28 23:49:06 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F41E1065673 for ; Thu, 28 Aug 2008 23:49:06 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 4A2678FC13 for ; Thu, 28 Aug 2008 23:49:05 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id D45E71A90E0; Thu, 28 Aug 2008 16:39:30 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.322 X-Spam-Level: X-Spam-Status: No, score=-4.322 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, AWL=0.077, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HNOXqA06v2jh; Thu, 28 Aug 2008 16:39:30 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 597BC1A90C3; Thu, 28 Aug 2008 16:39:30 -0700 (PDT) Message-ID: <48B73971.90706@miralink.com> Date: Thu, 28 Aug 2008 16:49:05 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808282313.XAA17597@sopwith.solgatos.com> In-Reply-To: <200808282313.XAA17597@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: Re: This is where I'm going with fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Aug 2008 23:49:06 -0000 Dieter wrote: > While looking at the code and wondering what "adjust_gap_count" > had to do with cyclemaster mode, I noticed that -f was setting > the 2nd argument to > send_phy_config(int fd, int root_node, int gap_count) > which is root_node, not gap_count. > > I also noticed that send_phy_config() does (root_node & 0x3f), > so having the range check be 0x3f rather than INT32_MAX > seems to make sense. > > Agreed, the root_node should be checked against 0x3f(or a define that is assigned the value of 0x3f ... whatever that really is). > I haven't yet figured out exactly which 7 bits this stuff is > actually setting. > > send_phy_config() is causing the /dev/fwX device to generate a PHY configuration Packet(IEEE 1394-1995 4.3.4.3) It is possible to optimize Serial Bus performance for particular configurations in the following ways: a) Setting the gap_count used by all nodes to a smaller value (appropriate to the actual worst-case number of hops between any two nodes) b) Forcing a particular node to be the root after the next bus initialization (for example, in isochronous systems, the root shall be cycle-master capable) Both of these actions shall be done for remote nodes using the PHY configuration packet shown in figure 4.20. (For the local node, the PH_CONT.request service is used) The procedures for using this PHY packet are described in clause 7.3.5.2.1. So, I think you are correct adjust_gap_count should become set_root_node as that is what it does. A PHY Config packet should look like this: Message ID Root ID R T Gap Count 00(2 bits) (5 bits) 1 1 (6 bits) So the Root ID(-f in fwcontrol) can't be set to a value greater than 0x3f(63) and the Gap Count can't be greater than 0x7f(127). An "R" value of 1 means that this is a message to set the root ID. An "T" value of 1 means that this is a message to set the gap count for all nodes. If "R" and "T" are both 0, then the message is ignored. > So does the following look like an improvement (however minor) > to anyone else, or just me? :-) > > > @@ -730,7 +730,7 @@ > bool dump_phy_reg = false; > > int32_t priority_budget = -1; > - int32_t adjust_gap_count = -1; > + int32_t set_root_node = -1; > int32_t reset_gap_count = -1; > int32_t send_link_on = -1; > int32_t send_reset_start = -1; > @@ -790,9 +790,9 @@ > display_board_only = false; > break; > case 'f': > - adjust_gap_count = strtol(optarg, NULL, 0); > - if ( (adjust_gap_count < 0) || (adjust_gap_count > INT32_MAX) ) > - err(EX_USAGE, "%s:adjust_gap_count out of range", __func__); > + set_root_node = strtol(optarg, NULL, 0); > + if ( (set_root_node < 0) || (set_root_node > 0x3f) ) > + err(EX_USAGE, "%s:set_root_node out of range", __func__); > open_needed = true; > command_set = true; > display_board_only = false; > @@ -961,8 +961,8 @@ > /* > * Adjust the gap count for this card/bus to value "-f" > */ > - if (adjust_gap_count >= 0) > - send_phy_config(fd, adjust_gap_count, -1); > + if (set_root_node >= 0) > + send_phy_config(fd, set_root_node, -1); > > /* > * Reset the gap count for this card/bus "-g" > I will chew on and implement this patch tomorrow I think. It makes sense to me, it's just the code in send_phy_config() that is distracting. I hope this clarifies what this crap means! :) -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 01:02:15 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E0C0106567C for ; Fri, 29 Aug 2008 01:02:15 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id D42FD8FC21 for ; Fri, 29 Aug 2008 01:02:14 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7T125v80720; Thu, 28 Aug 2008 18:02:05 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id BAA25511; Fri, 29 Aug 2008 01:01:09 GMT Message-Id: <200808290101.BAA25511@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Thu, 28 Aug 2008 16:49:05 PDT." <48B73971.90706@miralink.com> Date: Thu, 28 Aug 2008 18:01:09 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: This is where I'm going with fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 01:02:15 -0000 > send_phy_config() is causing the /dev/fwX device to generate a PHY > configuration Packet(IEEE 1394-1995 4.3.4.3) > > It is possible to optimize Serial Bus performance for particular > configurations in the following ways: > a) Setting the gap_count used by all nodes to a smaller value > (appropriate to the actual worst-case number of > hops between any two nodes) > b) Forcing a particular node to be the root after the next bus > initialization (for example, in isochronous systems, > the root shall be cycle-master capable) > Both of these actions shall be done for remote nodes using the PHY > configuration packet shown in figure 4.20. (For the > local node, the PH_CONT.request service is used) The procedures for > using this PHY packet are described in clause > 7.3.5.2.1. > > > So, I think you are correct adjust_gap_count should become set_root_node > as that is what it does. > > A PHY Config packet should look like this: > Message ID Root ID R T Gap Count > 00(2 bits) (5 bits) 1 1 (6 bits) > > So the Root ID(-f in fwcontrol) can't be set to a value greater than > 0x3f(63) and the Gap Count can't be greater than 0x7f(127). An "R" > value of 1 means that this is a message to set the root ID. An "T" > value of 1 means that this is a message to set the gap count for all > nodes. If "R" and "T" are both 0, then the message is ignored. Thank you, this makes much more sense now! I was looking at controller registers, but it is building a packet. Suggestion: put something like the text above in a comment at the start of send_phy_config(). From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 02:35:37 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CD942106564A for ; Fri, 29 Aug 2008 02:35:37 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 3EDDE8FC13 for ; Fri, 29 Aug 2008 02:35:37 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7T2ZSS80855; Thu, 28 Aug 2008 19:35:28 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id CAA18841; Fri, 29 Aug 2008 02:34:30 GMT Message-Id: <200808290234.CAA18841@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Thu, 28 Aug 2008 16:49:05 PDT." <48B73971.90706@miralink.com> Date: Thu, 28 Aug 2008 19:34:30 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: This is where I'm going with fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 02:35:37 -0000 More nit picking :-) Should > Message ID Root ID R T Gap Count > 00(2 bits) (5 bits) 1 1 (6 bits) be Message ID Root ID R T Gap Count 00(2 bits) (6 bits) 1 1 (6 bits) send_phy_config() ANDs root_node with 0x3f, and the "Physical ID" field in the controller register is 6 bits. From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 16:28:33 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D4E941065675 for ; Fri, 29 Aug 2008 16:28:33 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 1C2C88FC16 for ; Fri, 29 Aug 2008 16:28:29 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7TGS9a82586; Fri, 29 Aug 2008 09:28:09 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id QAA13259; Fri, 29 Aug 2008 16:26:53 GMT Message-Id: <200808291626.QAA13259@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Thu, 28 Aug 2008 16:49:05 PDT." <48B73971.90706@miralink.com> Date: Fri, 29 Aug 2008 09:26:53 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: This is where I'm going with fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 16:28:33 -0000 I looked at the changes NetBSD made to fwcontrol.c with the idea of tweaking FreeBSD's version so it would compile on both OSes. Below is a patch that might be enough. They made more changes than this. Some are clearly not essential (whitespace, putting the usage message into alphabetical order, ...), some I'm not sure about so I left them out for now. The full set of changes they did can be viewed by diffing FreeBSD cvs 1.23 with NetBSD cvs 1.7. It still compiles fine on FreeBSD 7.0 amd64, (and the getprogname() thing works) I haven't tried NetBSD yet. =================================================================== RCS file: RCS/fwcontrol.c,v retrieving revision 1.2.2.2 diff -u -r1.2.2.2 fwcontrol.c --- fwcontrol.c 2008/08/29 15:50:16 1.2.2.2 +++ fwcontrol.c 2008/08/29 16:00:48 @@ -32,8 +32,10 @@ * SUCH DAMAGE. */ +#if defined(__FreeBSD__) #include __FBSDID("$FreeBSD: src/usr.sbin/fwcontrol/fwcontrol.c,v 1.23.2.1 2008/05/02 06:15:58 simokawa Exp $"); +#endif #include #include @@ -42,11 +44,22 @@ #include #include #include +#if defined(__FreeBSD__) #include #include #include #include #include +#elif defined(__NetBSD__) +#include "eui64.h" +#include +#include +#include +#include +#else +#warning "You need to add support for your OS" +#endif + #include #include @@ -66,7 +79,7 @@ usage(void) { fprintf(stderr, - "fwcontrol [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n" + "%s [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n" "\t [-l file] [-g gap_count] [-f force_root ] [-b pri_req]\n" "\t [-M mode] [-R filename] [-S filename] [-m EUI64 | hostname]\n" "\t-u: specify bus number\n" @@ -84,7 +97,8 @@ "\t-M: specify dv or mpeg\n" "\t-R: Receive DV or MPEG TS stream\n" "\t-S: Send DV stream\n" - "\t-m: set fwmem target\n"); + "\t-m: set fwmem target\n" + , getprogname() ); exit(EX_USAGE); } @@ -981,8 +995,16 @@ if (set_fwmem_target) { eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); +#if defined(__FreeBSD__) sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi); sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo); +#elif defined(__NetBSD__) + sysctl_set_int("hw.fwmem.eui64_hi", eui.hi); + sysctl_set_int("hw.fwmem.eui64_lo", eui.lo); +#else +#warning "You need to add support for your OS" +#endif + } /* From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 17:55:36 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A85D1065689 for ; Fri, 29 Aug 2008 17:55:36 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 669638FC17 for ; Fri, 29 Aug 2008 17:55:36 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id AB6E91A91B6; Fri, 29 Aug 2008 10:45:51 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.34 X-Spam-Level: X-Spam-Status: No, score=-4.34 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, AWL=0.059, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QoxJYfcPmccq; Fri, 29 Aug 2008 10:45:51 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 3F0011A91B5; Fri, 29 Aug 2008 10:45:51 -0700 (PDT) Message-ID: <48B83817.8050508@miralink.com> Date: Fri, 29 Aug 2008 10:55:35 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808291626.QAA13259@sopwith.solgatos.com> In-Reply-To: <200808291626.QAA13259@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: Re: This is where I'm going with fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 17:55:36 -0000 Dieter wrote: > I looked at the changes NetBSD made to fwcontrol.c > with the idea of tweaking FreeBSD's version so it would > compile on both OSes. Below is a patch that might be enough. > They made more changes than this. Some are clearly not essential > (whitespace, putting the usage message into alphabetical order, ...), > some I'm not sure about so I left them out for now. The full set > of changes they did can be viewed by diffing FreeBSD cvs 1.23 > with NetBSD cvs 1.7. It still compiles fine on FreeBSD 7.0 amd64, > (and the getprogname() thing works) I haven't tried NetBSD yet. > > =================================================================== > RCS file: RCS/fwcontrol.c,v > retrieving revision 1.2.2.2 > diff -u -r1.2.2.2 fwcontrol.c > --- fwcontrol.c 2008/08/29 15:50:16 1.2.2.2 > +++ fwcontrol.c 2008/08/29 16:00:48 > @@ -32,8 +32,10 @@ > * SUCH DAMAGE. > */ > > +#if defined(__FreeBSD__) > #include > __FBSDID("$FreeBSD: src/usr.sbin/fwcontrol/fwcontrol.c,v 1.23.2.1 2008/05/02 06:15:58 simokawa Exp $"); > +#endif > > #include > #include > @@ -42,11 +44,22 @@ > #include > #include > #include > +#if defined(__FreeBSD__) > #include > #include > #include > #include > #include > +#elif defined(__NetBSD__) > +#include "eui64.h" > +#include > +#include > +#include > +#include > +#else > +#warning "You need to add support for your OS" > +#endif > + > > #include > #include > @@ -66,7 +79,7 @@ > usage(void) > { > fprintf(stderr, > - "fwcontrol [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n" > + "%s [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n" > "\t [-l file] [-g gap_count] [-f force_root ] [-b pri_req]\n" > "\t [-M mode] [-R filename] [-S filename] [-m EUI64 | hostname]\n" > "\t-u: specify bus number\n" > @@ -84,7 +97,8 @@ > "\t-M: specify dv or mpeg\n" > "\t-R: Receive DV or MPEG TS stream\n" > "\t-S: Send DV stream\n" > - "\t-m: set fwmem target\n"); > + "\t-m: set fwmem target\n" > + , getprogname() ); > exit(EX_USAGE); > } > > @@ -981,8 +995,16 @@ > if (set_fwmem_target) { > eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); > eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); > +#if defined(__FreeBSD__) > sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi); > sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo); > +#elif defined(__NetBSD__) > + sysctl_set_int("hw.fwmem.eui64_hi", eui.hi); > + sysctl_set_int("hw.fwmem.eui64_lo", eui.lo); > +#else > +#warning "You need to add support for your OS" > +#endif > + > } > > /* > Since my current patch-set is fairly extensive in it's current state, I'm going to defer application of this patch for a while. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 18:16:29 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C9A31065750 for ; Fri, 29 Aug 2008 18:16:29 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 4545A8FC16 for ; Fri, 29 Aug 2008 18:16:29 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id D4F0B1A91B6; Fri, 29 Aug 2008 11:06:43 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.344 X-Spam-Level: X-Spam-Status: No, score=-4.344 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, AWL=0.055, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X5AjLRNOq3gg; Fri, 29 Aug 2008 11:06:43 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 6E9D51A91B5; Fri, 29 Aug 2008 11:06:43 -0700 (PDT) Message-ID: <48B83CFC.6030906@miralink.com> Date: Fri, 29 Aug 2008 11:16:28 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808290234.CAA18841@sopwith.solgatos.com> In-Reply-To: <200808290234.CAA18841@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: Re: This is where I'm going with fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 18:16:29 -0000 Dieter wrote: > More nit picking :-) > > Should > > >> Message ID Root ID R T Gap Count >> 00(2 bits) (5 bits) 1 1 (6 bits) >> > > be > > Message ID Root ID R T Gap Count > 00(2 bits) (6 bits) 1 1 (6 bits) > > send_phy_config() ANDs root_node with 0x3f, and the > "Physical ID" field in the controller register is > 6 bits. > Well, according to the 1394 documentation, no. The root ID is definitely 5 bits. The gap count is also 5 bits, I must have mis-counted. So, really it should be: Message ID Root ID R T Gap Count 00(2 bits) (5 bits) 1 1 (5 bits) This means that the Root ID and the Gap Count cannot exceed 0x3f(63). So, the masking of the values instead of generating and error seems wrong to me. I'm going to put in error checking to make sure the values comply with the specification and document the correct values in the man page and the comments of the code. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 20:22:42 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 75D6B106566C for ; Fri, 29 Aug 2008 20:22:42 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id BFA928FC25 for ; Fri, 29 Aug 2008 20:22:41 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7TKMTK82925; Fri, 29 Aug 2008 13:22:29 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id UAA25442; Fri, 29 Aug 2008 20:21:25 GMT Message-Id: <200808292021.UAA25442@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Fri, 29 Aug 2008 11:16:28 PDT." <48B83CFC.6030906@miralink.com> Date: Fri, 29 Aug 2008 13:21:25 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: This is where I'm going with fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 20:22:42 -0000 > > Should > > > > > >> Message ID Root ID R T Gap Count > >> 00(2 bits) (5 bits) 1 1 (6 bits) > >> > > > > be > > > > Message ID Root ID R T Gap Count > > 00(2 bits) (6 bits) 1 1 (6 bits) > > > > send_phy_config() ANDs root_node with 0x3f, and the > > "Physical ID" field in the controller register is > > 6 bits. > > > Well, according to the 1394 documentation, no. The root ID is > definitely 5 bits. > > The gap count is also 5 bits, I must have mis-counted. So, really it > should be: > > Message ID Root ID R T Gap Count > 00(2 bits) (5 bits) 1 1 (5 bits) Looking at "Table 5. PHY Register Map" in the VIA controller datasheet (page 24 of the pdf) http://www.datasheetarchive.com/pdf-datasheets/Datasheets-6/DSA-113181.pdf the "Physical ID" field is 6 bits, as is the "Gap Count" field. I don't have the IEEE documentation, so I'll have to assume you are correct about it saying 5 bits. So why doesn't the controller datasheet agree with the IEEE doc? Granted one is a controller register and the other is a packet, but I'd expect these individual fields to be the same size. > This means that the Root ID and the Gap Count cannot exceed 0x3f(63). That's 6 bits. 5 bits would be 0x1f = 31 decimal. > So, the masking > of the values instead of generating and error seems wrong to me. I'm > going to put in error checking > to make sure the values comply with the specification and document the > correct values in the man page > and the comments of the code. Sounds good. From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 21:02:52 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8CDFF1065687 for ; Fri, 29 Aug 2008 21:02:52 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 695388FC0A for ; Fri, 29 Aug 2008 21:02:52 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 0C3051A91B6; Fri, 29 Aug 2008 13:53:06 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.354 X-Spam-Level: X-Spam-Status: No, score=-4.354 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, AWL=0.046, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aovmx9JSpGbx; Fri, 29 Aug 2008 13:53:05 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 4E46D1A91A0; Fri, 29 Aug 2008 13:53:05 -0700 (PDT) Message-ID: <48B863FB.10202@miralink.com> Date: Fri, 29 Aug 2008 14:02:51 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808292021.UAA25442@sopwith.solgatos.com> In-Reply-To: <200808292021.UAA25442@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: Re: This is where I'm going with fwcontrol X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 21:02:52 -0000 Dieter wrote: >>> Should >>> >>> >>> >>>> Message ID Root ID R T Gap Count >>>> 00(2 bits) (5 bits) 1 1 (6 bits) >>>> >>>> >>> >>> be >>> >>> Message ID Root ID R T Gap Count >>> 00(2 bits) (6 bits) 1 1 (6 bits) >>> >>> send_phy_config() ANDs root_node with 0x3f, and the >>> "Physical ID" field in the controller register is >>> 6 bits. >>> >>> >> Well, according to the 1394 documentation, no. The root ID is >> definitely 5 bits. >> >> The gap count is also 5 bits, I must have mis-counted. So, really it >> should be: >> >> Message ID Root ID R T Gap Count >> 00(2 bits) (5 bits) 1 1 (5 bits) >> > > Looking at "Table 5. PHY Register Map" in the VIA controller datasheet > (page 24 of the pdf) > http://www.datasheetarchive.com/pdf-datasheets/Datasheets-6/DSA-113181.pdf > > the "Physical ID" field is 6 bits, as is the "Gap Count" field. > I don't have the IEEE documentation, so I'll have to assume > you are correct about it saying 5 bits. So why doesn't the > controller datasheet agree with the IEEE doc? Granted one is > a controller register and the other is a packet, but I'd > expect these individual fields to be the same size. > > >> This means that the Root ID and the Gap Count cannot exceed 0x3f(63). >> > > That's 6 bits. 5 bits would be 0x1f = 31 decimal. > > Huh....I seem to be having some kind of wierd PDF rendering issue. Ok, so looking at the document in another application(not acroread), the Node ID is 6 bits, the Gap Count is 6 bits. I'm the crazy one I guess. Wierd. >> So, the masking >> of the values instead of generating and error seems wrong to me. I'm >> going to put in error checking >> to make sure the values comply with the specification and document the >> correct values in the man page >> and the comments of the code. >> > > Sounds good. > -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 21:18:12 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DEF3C106566C for ; Fri, 29 Aug 2008 21:18:12 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id AAD5D8FC0C for ; Fri, 29 Aug 2008 21:18:12 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 20E3A1A91B6; Fri, 29 Aug 2008 14:08:26 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.356 X-Spam-Level: X-Spam-Status: No, score=-4.356 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, AWL=0.043, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HqAM-fqgoEja; Fri, 29 Aug 2008 14:08:25 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id EC2191A91A0; Fri, 29 Aug 2008 14:08:24 -0700 (PDT) Message-ID: <48B86793.6080404@miralink.com> Date: Fri, 29 Aug 2008 14:18:11 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: freebsd-firewire@freebsd.org, Dieter Content-Type: multipart/mixed; boundary="------------020006060308070201060902" Cc: Subject: New and improved? patch X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 21:18:13 -0000 This is a multi-part message in MIME format. --------------020006060308070201060902 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Freshly updated with new found information on what the heck -f -g actually do! See how this behaves for you. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com --------------020006060308070201060902 Content-Type: text/plain; name="fwcontrol.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fwcontrol.diff" Index: fwcontrol.8 =================================================================== --- fwcontrol.8 (revision 182455) +++ fwcontrol.8 (working copy) @@ -59,7 +59,7 @@ The following options are available: .Bl -tag -width indent .It Fl u Ar bus_num -Specify the FireWire bus number to be operated on. +Specify the FireWire bus number to be operated on. Default is bus 0. .It Fl r Initiate bus reset. .It Fl t @@ -81,11 +81,14 @@ .It Fl f Ar node Force specified .Ar node -to be the root node on the next bus reset. +to be the root node on the next bus reset by sending a PHY config packet. +Valid values are 0 - 63. .It Fl g Ar gap_count -Broadcast +Broadcast new .Ar gap_count -by phy_config packet. +by sending a PHY_config packet. +By default this value is 63 on all nodes. +Valid values are 0 - 63. .It Fl i Ar pri_req Set the .Dv PRIORITY_BUDGET Index: fwcontrol.c =================================================================== --- fwcontrol.c (revision 182455) +++ fwcontrol.c (working copy) @@ -56,6 +56,8 @@ #include #include #include +#include +#include #include "fwmethods.h" static void sysctl_set_int(const char *, int); @@ -64,21 +66,22 @@ usage(void) { fprintf(stderr, - "fwcontrol [-u bus_num] [-rt] [-f node] [-g gap_count] " - "[-o node] " - "[-b pri_req] [-c node] [-d node] [-l file] " - "[-R file] [-S file] [-m target]\n" + "fwcontrol [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n" + "\t [-l file] [-g gap_count] [-f force_root ] [-b pri_req]\n" + "\t [-M mode] [-R filename] [-S filename] [-m EUI64 | hostname]\n" "\t-u: specify bus number\n" - "\t-f: broadcast force_root by phy_config packet\n" - "\t-g: broadcast gap_count by phy_config packet\n" - "\t-o: send link-on packet to the node\n" - "\t-s: write RESET_START register on the node\n" - "\t-b: set PRIORITY_BUDGET register on all supported nodes\n" - "\t-c: read configuration ROM\n" + "\t-p: Display current PHY register settings\n" "\t-r: bus reset\n" "\t-t: read topology map\n" + "\t-c: read configuration ROM\n" "\t-d: hex dump of configuration ROM\n" + "\t-o: send link-on packet to the node\n" + "\t-s: write RESET_START register on the node\n" "\t-l: load and parse hex dump file of configuration ROM\n" + "\t-g: broadcast gap_count by phy_config packet\n" + "\t-f: broadcast force_root by phy_config packet\n" + "\t-b: set PRIORITY_BUDGET register on all supported nodes\n" + "\t-M: specify dv or mpeg\n" "\t-R: Receive DV or MPEG TS stream\n" "\t-S: Send DV stream\n" "\t-m: set fwmem target\n"); @@ -92,18 +95,14 @@ *(u_int32_t*)&(eui->octet[4]) = htonl(fweui->lo); } -static struct fw_devlstreq * -get_dev(int fd) +static void +get_dev(int fd, struct fw_devlstreq *data) { - struct fw_devlstreq *data; - - data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); if (data == NULL) - err(1, "malloc"); + err(EX_SOFTWARE, "%s: data malloc", __func__); if( ioctl(fd, FW_GDEVLST, data) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } - return data; } static int @@ -130,17 +129,25 @@ if (eui64_hostton(nodestr, &eui) != 0 && eui64_aton(nodestr, &eui) != 0) return (-1); - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s: data malloc", __func__); + get_dev(fd,data); for (i = 0; i < data->info_len; i++) { fweui2eui64(&data->dev[i].eui, &tmpeui); if (memcmp(&eui, &tmpeui, sizeof(struct eui64)) == 0) { node = data->dev[i].dst; + if (data != NULL) + free(data); goto gotnode; } } - if (i >= data->info_len) + if (i >= data->info_len) { + if (data != NULL) + free(data); return (-1); + } gotnode: if (node < 0 || node > 63) @@ -158,7 +165,10 @@ char addr[EUI64_SIZ], hostname[40]; int i; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); printf("%d devices (info_len=%d)\n", data->n, data->info_len); printf("node EUI64 status hostname\n"); for (i = 0; i < data->info_len; i++) { @@ -184,6 +194,8 @@ u_int32_t *qld, res; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 16); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 16; #if 0 asyreq->req.type = FWASREQNODE; @@ -206,7 +218,7 @@ asyreq->pkt.mode.wreqq.data = htonl(data); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } res = qld[3]; free(asyreq); @@ -216,37 +228,56 @@ return 0; } +/* + * Send a PHY Config Packet + * ieee 1394a-2005 4.3.4.3 + * + * Message ID Root ID R T Gap Count + * 00(2 bits) (6 bits) 1 1 (6 bits) + * + * if "R" is set, then Root ID will be the next + * root node upon the next bus reset. + * if "T" is set, then Gap Count will be the + * value that all nodes use for their Gap Count + * if "R" and "T" are not set, then this message + * is either ignored or interpreted as an extended + * PHY config Packet as per 1394a-2005 4.3.4.4 + */ static void send_phy_config(int fd, int root_node, int gap_count) { struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 12); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 12; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.ld[0] = 0; asyreq->pkt.mode.ld[1] = 0; asyreq->pkt.mode.common.tcode = FWTCODE_PHY; if (root_node >= 0) - asyreq->pkt.mode.ld[1] |= (root_node & 0x3f) << 24 | 1 << 23; + asyreq->pkt.mode.ld[1] |= ((root_node << 24) | (1 << 23)); if (gap_count >= 0) - asyreq->pkt.mode.ld[1] |= 1 << 22 | (gap_count & 0x3f) << 16; + asyreq->pkt.mode.ld[1] |= ((1 << 22) | (gap_count << 16)); asyreq->pkt.mode.ld[2] = ~asyreq->pkt.mode.ld[1]; printf("send phy_config root_node=%d gap_count=%d\n", root_node, gap_count); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } static void -send_link_on(int fd, int node) +link_on(int fd, int node) { struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 12); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 12; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.common.tcode = FWTCODE_PHY; @@ -254,7 +285,7 @@ asyreq->pkt.mode.ld[2] = ~asyreq->pkt.mode.ld[1]; if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } @@ -264,6 +295,8 @@ struct fw_asyreq *asyreq; asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 16); + if (asyreq == NULL) + err(EX_SOFTWARE, "%s:asyreq malloc", __func__); asyreq->req.len = 16; asyreq->req.type = FWASREQNODE; asyreq->pkt.mode.wreqq.dst = FWLOCALBUS | (node & 0x3f); @@ -276,7 +309,7 @@ asyreq->pkt.mode.wreqq.data = htonl(0x1); if (ioctl(fd, FW_ASYREQ, asyreq) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); free(asyreq); } @@ -290,7 +323,10 @@ u_int32_t max, reg, old; int i; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); #define BUGET_REG 0xf0000218 for (i = 0; i < data->info_len; i++) { devinfo = &data->dev[i]; @@ -344,7 +380,10 @@ int i, error; struct fw_devlstreq *data; - data = get_dev(fd); + data = (struct fw_devlstreq *)malloc(sizeof(struct fw_devlstreq)); + if (data == NULL) + err(EX_SOFTWARE, "%s:data malloc", __func__); + get_dev(fd, data); for (i = 0; i < data->info_len; i++) { if (data->dev[i].dst == node && data->dev[i].eui.lo != 0) @@ -360,7 +399,7 @@ buf.ptr = crom_buf; bzero(crom_buf, len); if ((error = ioctl(fd, FW_GCROM, &buf)) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } return error; @@ -469,9 +508,9 @@ static const char *speed[] = {"S100", "S200", "S400", "S800"}; tmap = malloc(sizeof(struct fw_topology_map)); if (tmap == NULL) - return; + err(EX_SOFTWARE, "%s:tmap malloc", __func__); if (ioctl(fd, FW_GTPMAP, tmap) < 0) { - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); } printf("crc_len: %d generation:%d node_count:%d sid_count:%d\n", tmap->crc_len, tmap->generation, @@ -512,7 +551,7 @@ for (i = 0; i < len; i++) { reg.addr = offset + i; if (ioctl(fd, FWOHCI_RDPHYREG, ®) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); buf[i] = (u_int8_t) reg.data; printf("0x%02x ", reg.data); } @@ -527,7 +566,7 @@ reg.addr = 0x7; reg.data = ((page & 7) << 5) | (port & 0xf); if (ioctl(fd, FWOHCI_WRPHYREG, ®) < 0) - err(1, "ioctl"); + err(EX_IOERR, "%s: ioctl", __func__); read_phy_registers(fd, buf, 8, 8); } @@ -590,22 +629,16 @@ ); } -static void -open_dev(int *fd, char *devbase) +static int +open_dev(int *fd, char *devname) { - char name[256]; - int i; - if (*fd < 0) { - for (i = 0; i < 4; i++) { - snprintf(name, sizeof(name), "%s.%d", devbase, i); - if ((*fd = open(name, O_RDWR)) >= 0) - break; - } + *fd = open(devname, O_RDWR); if (*fd < 0) - err(1, "open"); + return(-1); } + return(0); } static void @@ -625,25 +658,40 @@ u_int32_t *ptr; struct ciphdr *ciph; fwmethod *retfn; +#define RECV_NUM_PACKET 16 +#define RECV_PACKET_SZ 1024 bufreq.rx.nchunk = 8; - bufreq.rx.npacket = 16; - bufreq.rx.psize = 1024; + bufreq.rx.npacket = RECV_NUM_PACKET; + bufreq.rx.psize = RECV_PACKET_SZ; bufreq.tx.nchunk = 0; bufreq.tx.npacket = 0; bufreq.tx.psize = 0; if (ioctl(fd, FW_SSTBUF, &bufreq) < 0) - err(1, "ioctl FW_SSTBUF"); + err(EX_IOERR, "%s: ioctl FW_SSTBUF", __func__); isoreq.ch = ich & 0x3f; isoreq.tag = (ich >> 6) & 3; if (ioctl(fd, FW_SRSTREAM, &isoreq) < 0) - err(1, "ioctl FW_SRSTREAM"); + err(EX_IOERR, "%s: ioctl FW_SRSTREAM", __func__); - buf = (char *)malloc(1024*16); - len = read(fd, buf, 1024*16); + buf = (char *)malloc(RECV_NUM_PACKET * RECV_PACKET_SZ); + if (buf == NULL) + err(EX_SOFTWARE, "%s:buf malloc", __func__); + /* + * fwdev.c seems to return EIO on error and + * the return value of the last uiomove + * on success. For now, checking that the + * return is not less than zero should be + * sufficient. fwdev.c::fw_read() should + * return the total length read, not the value + * of the last uiomove(). + */ + len = read(fd, buf, RECV_NUM_PACKET * RECV_PACKET_SZ); + if (len < 0) + err(EX_IOERR, "%s: error reading from device\n", __func__); ptr = (u_int32_t *) buf; ciph = (struct ciphdr *)(ptr + 1); @@ -666,102 +714,168 @@ int main(int argc, char **argv) { +#define MAX_BOARDS 10 u_int32_t crom_buf[1024/4]; - char devbase[1024] = "/dev/fw0"; - int fd, ch, len=1024; + u_int32_t crom_buf_hex[1024/4]; + char devbase[64]; + const char *device_string = "/dev/fw"; + int fd = -1, ch, len=1024; + int32_t current_board = 0; + /* + * If !command_set, then -u will display the nodes for the board. + * This emulates the previous behavior when -u is passed by itself + */ + bool command_set = false; + bool open_needed = false; long tmp; struct fw_eui64 eui; struct eui64 target; fwmethod *recvfn = NULL; +/* + * Holders for which functions + * to iterate through + */ + bool display_board_only = false; + bool display_crom = false; + bool send_bus_reset = false; + bool display_crom_hex = false; + bool load_crom_from_file = false; + bool set_fwmem_target = false; + bool dump_topology = false; + bool dump_phy_reg = false; - fd = -1; + int32_t priority_budget = -1; + int32_t set_root_node = -1; + int32_t set_gap_count = -1; + int32_t send_link_on = -1; + int32_t send_reset_start = -1; + char *crom_string = NULL; + char *crom_string_hex = NULL; + char *recv_data = NULL; + char *send_data = NULL; + if (argc < 2) { - open_dev(&fd, devbase); - list_dev(fd); + for (current_board = 0; current_board < MAX_BOARDS; current_board++) { + snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + if (open_dev(&fd, devbase) < 0) { + if (current_board == 0) { + usage(); + } + return(EIO); + } + list_dev(fd); + close(fd); + fd = -1; + } } - - while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) + /* + * Parse all command line options, then execute requested operations. + */ + while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) { switch(ch) { case 'b': - tmp = strtol(optarg, NULL, 0); - if (tmp < 0 || tmp > (long)0xffffffff) - errx(EX_USAGE, "invalid number: %s", optarg); - open_dev(&fd, devbase); - set_pri_req(fd, tmp); + priority_budget = strtol(optarg, NULL, 0); + if (priority_budget < 0 || priority_budget > INT32_MAX) + errx(EX_USAGE, "%s: invalid number: %s", __func__, optarg); + command_set = true; + open_needed = true; + display_board_only = false; break; case 'c': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - get_crom(fd, tmp, crom_buf, len); - show_crom(crom_buf); + crom_string = malloc(strlen(optarg)+1); + if (crom_string == NULL) + err(EX_SOFTWARE, "%s:crom_string malloc", __func__); + if ( (strtol(crom_string, NULL, 0) < 0) || strtol(crom_string, NULL, 0) > MAX_BOARDS) + err(EX_USAGE, "%s:Invalid value for node", __func__); + strcpy(crom_string, optarg); + display_crom = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'd': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - get_crom(fd, tmp, crom_buf, len); - dump_crom(crom_buf); + crom_string_hex = malloc(strlen(optarg)+1); + if (crom_string_hex == NULL) + err(EX_SOFTWARE, "%s:crom_string_hex malloc", __func__); + strcpy(crom_string_hex, optarg); + display_crom_hex = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'f': - tmp = strtol(optarg, NULL, 0); - open_dev(&fd, devbase); - send_phy_config(fd, tmp, -1); +#define MAX_PHY_CONFIG 0x3f + set_root_node = strtol(optarg, NULL, 0); + if ( (set_root_node < 0) || (set_root_node > MAX_PHY_CONFIG) ) + err(EX_USAGE, "%s:set_root_node out of range", __func__); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'g': - tmp = strtol(optarg, NULL, 0); - open_dev(&fd, devbase); - send_phy_config(fd, -1, tmp); + set_gap_count = strtol(optarg, NULL, 0); + if ( (set_gap_count < 0) || (set_gap_count > MAX_PHY_CONFIG) ) + err(EX_USAGE, "%s:set_gap_count out of range", __func__); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'l': + load_crom_from_file = 1; load_crom(optarg, crom_buf); - show_crom(crom_buf); + command_set = true; + display_board_only = false; break; case 'm': - if (eui64_hostton(optarg, &target) != 0 && - eui64_aton(optarg, &target) != 0) - errx(EX_USAGE, "invalid target: %s", optarg); - eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); - eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); - sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi); - sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo); + set_fwmem_target = 1; + open_needed = 0; + command_set = true; + display_board_only = false; + if (eui64_hostton(optarg, &target) != 0 && + eui64_aton(optarg, &target) != 0) + err(EX_USAGE, "%s: invalid target: %s", __func__, optarg); break; case 'o': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - send_link_on(fd, tmp); + send_link_on = str2node(fd, optarg); + if ( (send_link_on < 0) || (send_link_on > INT32_MAX) ) + err(EX_USAGE, "%s: node out of range: %s\n",__func__, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; case 'p': - open_dev(&fd, devbase); - dump_phy_registers(fd); + dump_phy_reg = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'r': - open_dev(&fd, devbase); - if(ioctl(fd, FW_IBUSRST, &tmp) < 0) - err(1, "ioctl"); + send_bus_reset = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 's': - open_dev(&fd, devbase); - tmp = str2node(fd, optarg); - reset_start(fd, tmp); + send_reset_start = str2node(fd, optarg); + if ( (send_reset_start < 0) || (send_reset_start > INT32_MAX) ) + err(EX_USAGE, "%s: node out of range: %s\n", __func__, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; case 't': - open_dev(&fd, devbase); - show_topology_map(fd); + dump_topology = 1; + open_needed = true; + command_set = true; + display_board_only = false; break; case 'u': - tmp = strtol(optarg, NULL, 0); - snprintf(devbase, sizeof(devbase), "/dev/fw%ld", tmp); - if (fd > 0) { - close(fd); - fd = -1; - } - if (argc == optind) { - open_dev(&fd, devbase); - list_dev(fd); - } + if(!command_set) + display_board_only = true; + current_board = strtol(optarg, NULL, 0); + open_needed = true; break; -#define TAG (1<<6) -#define CHANNEL 63 case 'M': switch (optarg[0]) { case 'm': @@ -774,22 +888,164 @@ errx(EX_USAGE, "unrecognized method: %s", optarg); } + command_set = true; + display_board_only = false; break; case 'R': - open_dev(&fd, devbase); - if (recvfn == NULL) /* guess... */ - recvfn = detect_recv_fn(fd, TAG | CHANNEL); - close(fd); - fd = -1; - open_dev(&fd, devbase); - (*recvfn)(fd, optarg, TAG | CHANNEL, -1); + recv_data = malloc(strlen(optarg)+1); + if (recv_data == NULL) + err(EX_SOFTWARE, "%s:recv_data malloc", __func__); + strcpy(recv_data, optarg); + open_needed = false; + command_set = true; + display_board_only = false; break; case 'S': - open_dev(&fd, devbase); - dvsend(fd, optarg, TAG | CHANNEL, -1); + send_data = malloc(strlen(optarg)+1); + if (send_data == NULL) + err(EX_SOFTWARE, "%s:send_data malloc", __func__); + strcpy(send_data, optarg); + open_needed = true; + command_set = true; + display_board_only = false; break; default: usage(); + return 0; } + } /* end while */ + + /* + * If -u is passed, execute + * command for that card only. + * + * If -u is not passed, execute + * command for card 0 only. + * + */ + if(open_needed){ + snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + if (open_dev(&fd, devbase) < 0) { + errx(EX_IOERR, "%s: Error opening board #%d\n", __func__, current_board); + } + } + /* + * display the nodes on this board "-u" + * only + */ + if (display_board_only) + list_dev(fd); + + /* + * dump_phy_reg "-p" + */ + if (dump_phy_reg) + dump_phy_registers(fd); + + /* + * send a BUS_RESET Event "-r" + */ + if (send_bus_reset) { + if(ioctl(fd, FW_IBUSRST, &tmp) < 0) + err(EX_IOERR, "%s: ioctl", __func__); + } + /* + * Print out the CROM for this node "-c" + */ + if (display_crom) { + tmp = str2node(fd, crom_string); + get_crom(fd, tmp, crom_buf, len); + show_crom(crom_buf); + free(crom_string); + } + /* + * Hex Dump the CROM for this node "-d" + */ + if (display_crom_hex) { + tmp = str2node(fd, crom_string_hex); + get_crom(fd, tmp, crom_buf_hex, len); + dump_crom(crom_buf_hex); + free(crom_string_hex); + } + /* + * Set Priority Budget to value for this node "-b" + */ + if (priority_budget >= 0) + set_pri_req(fd, priority_budget); + + /* + * Explicitly set the root node of this bus to value "-f" + */ + if (set_root_node >= 0) + send_phy_config(fd, set_root_node, -1); + + /* + * Set the gap count for this card/bus "-g" + */ + if (set_gap_count >= 0) + send_phy_config(fd, -1, set_gap_count); + + /* + * Load a CROM from a file "-l" + */ + if (load_crom_from_file) + show_crom(crom_buf); + /* + * Set the fwmem target for a node to argument "-m" + */ + if (set_fwmem_target) { + eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); + eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); + sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi); + sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo); + } + + /* + * Send a link on to this board/bus "-o" + */ + if (send_link_on >= 0) + link_on(fd, send_link_on); + + /* + * Send a reset start to this board/bus "-s" + */ + if (send_reset_start >= 0) + reset_start(fd, send_reset_start); + + /* + * Dump the node topology for this board/bus "-t" + */ + if (dump_topology) + show_topology_map(fd); + + /* + * Recieve data file from node "-R" + */ +#define TAG (1<<6) +#define CHANNEL 63 + if (recv_data != NULL){ + if (recvfn == NULL) { /* guess... */ + recvfn = detect_recv_fn(fd, TAG | CHANNEL); + close(fd); + } + snprintf(devbase, sizeof(devbase), "%s%d", device_string, current_board); + if (open_dev(&fd, devbase) < 0) + errx(EX_IOERR, "%s: Error opening board #%d in recv_data\n", __func__, current_board); + (*recvfn)(fd, recv_data, TAG | CHANNEL, -1); + free(recv_data); + } + + /* + * Send data file to node "-S" + */ + if (send_data != NULL){ + dvsend(fd, send_data, TAG | CHANNEL, -1); + free(send_data); + } + + if (fd > 0) { + close(fd); + fd = -1; + } return 0; } --------------020006060308070201060902-- From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 21:42:54 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 07ECF1065677 for ; Fri, 29 Aug 2008 21:42:54 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id DEB3C8FC16 for ; Fri, 29 Aug 2008 21:42:53 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 29A851A91B6; Fri, 29 Aug 2008 14:33:07 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.358 X-Spam-Level: X-Spam-Status: No, score=-4.358 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, AWL=0.041, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tYmpGSJ2kWAu; Fri, 29 Aug 2008 14:33:06 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id BAEA81A90C8; Fri, 29 Aug 2008 14:33:06 -0700 (PDT) Message-ID: <48B86D5D.8060908@miralink.com> Date: Fri, 29 Aug 2008 14:42:53 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: DEBUG flag in fwdv.c X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 21:42:54 -0000 Oooooo...there's a "DEBUG" compile flag in fwdv.c ... care to set it to "1" and send me the output? It might clue me into what bit needs to be toggled to get your card back into shape. -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 23:32:34 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ECA16106566B for ; Fri, 29 Aug 2008 23:32:34 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from parsely.rain.com (parsely.rain.com [199.26.172.196]) by mx1.freebsd.org (Postfix) with ESMTP id 71C138FC20 for ; Fri, 29 Aug 2008 23:32:34 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (uucp@localhost) by parsely.rain.com (8.11.4/8.11.4) with UUCP id m7TNWQj83190; Fri, 29 Aug 2008 16:32:26 -0700 (PDT) (envelope-from freebsd@sopwith.solgatos.com) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id XAA01489; Fri, 29 Aug 2008 23:31:34 GMT Message-Id: <200808292331.XAA01489@sopwith.solgatos.com> To: Sean Bruno In-reply-to: Your message of "Fri, 29 Aug 2008 14:42:53 PDT." <48B86D5D.8060908@miralink.com> Date: Fri, 29 Aug 2008 16:31:34 +0100 From: Dieter Cc: freebsd-firewire@freebsd.org Subject: Re: DEBUG flag in fwdv.c X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 23:32:35 -0000 > Oooooo...there's a "DEBUG" compile flag in fwdv.c ... care to set it to > "1" and send me the output? It might clue me into what bit needs to be > toggled to get your card back into shape. Which problem is this for? http://www.freebsd.org/cgi/query-pr.cgi?pr=113785 http://www.freebsd.org/cgi/query-pr.cgi?pr=118093 I thought the idea for PR 113785 was to get the controller into non-CYCLEMASTER mode? I can't figure out why fwcontrol -f works for NCR but not for VIA? I don't see what fwdv.c has to do with PR 118093. If you mean the NCR controller generating hundreds of bus resets, the power cycle fixed it. From owner-freebsd-firewire@FreeBSD.ORG Fri Aug 29 23:33:48 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BDF5B106566B for ; Fri, 29 Aug 2008 23:33:48 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 9FBD38FC1A for ; Fri, 29 Aug 2008 23:33:48 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id CD10E1A9138; Fri, 29 Aug 2008 16:24:00 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.362 X-Spam-Level: X-Spam-Status: No, score=-4.362 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, AWL=0.037, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ddemL1tG90d7; Fri, 29 Aug 2008 16:24:00 -0700 (PDT) Received: from [10.0.0.40] (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 8406D1A9136; Fri, 29 Aug 2008 16:24:00 -0700 (PDT) Message-ID: <48B8875B.1010801@miralink.com> Date: Fri, 29 Aug 2008 16:33:47 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Dieter References: <200808292331.XAA01489@sopwith.solgatos.com> In-Reply-To: <200808292331.XAA01489@sopwith.solgatos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-firewire@freebsd.org Subject: Re: DEBUG flag in fwdv.c X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 23:33:48 -0000 Dieter wrote: >> Oooooo...there's a "DEBUG" compile flag in fwdv.c ... care to set it to >> "1" and send me the output? It might clue me into what bit needs to be >> toggled to get your card back into shape. >> > > Which problem is this for? > > http://www.freebsd.org/cgi/query-pr.cgi?pr=113785 > http://www.freebsd.org/cgi/query-pr.cgi?pr=118093 > > I thought the idea for PR 113785 was to get the controller into > non-CYCLEMASTER mode? I can't figure out why fwcontrol -f works > for NCR but not for VIA? > > I don't see what fwdv.c has to do with PR 118093. > > If you mean the NCR controller generating hundreds of bus resets, > the power cycle fixed it. > Ah, so with the original fwcontrol you can still do everything that you used to do? I was under the impression that I had permanently destroyed something! :) -- Sean Bruno MiraLink Corporation 6015 NE 80th Ave, Ste 100 Portland, OR 97218 Phone 503-621-5143 Fax 503-621-5199 MSN: sbruno@miralink.com Google: seanwbruno@gmail.com Yahoo: sean_bruno@yahoo.com