From owner-freebsd-firewire@FreeBSD.ORG Mon Feb 4 11:06:58 2008 Return-Path: Delivered-To: freebsd-firewire@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E64816A417 for ; Mon, 4 Feb 2008 11:06:58 +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 10C9C13C455 for ; Mon, 4 Feb 2008 11:06:58 +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 m14B6vYA017227 for ; Mon, 4 Feb 2008 11:06:57 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m14B6viM017223 for freebsd-firewire@FreeBSD.org; Mon, 4 Feb 2008 11:06:57 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 4 Feb 2008 11:06:57 GMT Message-Id: <200802041106.m14B6viM017223@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, 04 Feb 2008 11:06:58 -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 -------------------------------------------------------------------------------- f kern/113785 firewire [firewire] dropouts when playing DV on firewire 1 problem total. From owner-freebsd-firewire@FreeBSD.ORG Mon Feb 4 23:21:57 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 1F01A16A46B; Mon, 4 Feb 2008 23:21:57 +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 0013513C4D3; Mon, 4 Feb 2008 23:21:56 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id B09E961B9DE; Mon, 4 Feb 2008 15:21:56 -0800 (PST) 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 19590-04; Mon, 4 Feb 2008 15:21:56 -0800 (PST) Received: from iago.office.miralink.com (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 3FCCE61B96C; Mon, 4 Feb 2008 15:21:56 -0800 (PST) Message-ID: <47A79E13.5040706@miralink.com> Date: Mon, 04 Feb 2008 15:21:55 -0800 From: Sean Bruno User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Hidetoshi Shimokawa , freebsd-firewire@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-DSPAM-Result: Innocent X-DSPAM-Processed: Mon Feb 4 15:21:56 2008 X-DSPAM-Confidence: 0.9995 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 47a79e14307521109565483 X-DSPAM-Factors: 27, X-Virus-Scanned: amavisd-new at X-Spam-Status: No, score=-4.499 tagged_above=-10 required=6.6 autolearn=ham tests=[ALL_TRUSTED=-1.8, AWL=-0.000, BAYES_00=-2.599, DSPAM_HAM=-0.1] X-Spam-Score: -4.499 X-Spam-Level: Cc: Subject: Implementation of the AGENT_STATE Register 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, 04 Feb 2008 23:21:57 -0000 Hidetoshi: I'm attempting to implement the AGENT_STATE register in sbp_targ. Somehow, I can't understand how to sent the agent state back to the initiator. I am processing the request, but I am really unsure how to return the state(what function calls?). Sean From owner-freebsd-firewire@FreeBSD.ORG Tue Feb 5 04:20:43 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 B7D2816A417 for ; Tue, 5 Feb 2008 04:20:43 +0000 (UTC) (envelope-from freebsd@gm.nunu.org) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.250]) by mx1.freebsd.org (Postfix) with ESMTP id 7CA1713C447 for ; Tue, 5 Feb 2008 04:20:43 +0000 (UTC) (envelope-from freebsd@gm.nunu.org) Received: by an-out-0708.google.com with SMTP id c14so656134anc.13 for ; Mon, 04 Feb 2008 20:20:42 -0800 (PST) Received: by 10.100.227.20 with SMTP id z20mr544730ang.48.1202185242424; Mon, 04 Feb 2008 20:20:42 -0800 (PST) Received: by 10.100.247.18 with HTTP; Mon, 4 Feb 2008 20:20:42 -0800 (PST) Message-ID: <626eb4530802042020n78001c00kddbdedb907902691@mail.gmail.com> Date: Tue, 5 Feb 2008 13:20:42 +0900 From: "Hidetoshi Shimokawa" Sender: freebsd@gm.nunu.org To: "Sean Bruno" In-Reply-To: <47A79E13.5040706@miralink.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <47A79E13.5040706@miralink.com> X-Google-Sender-Auth: 539989be7aa37138 Cc: freebsd-firewire@freebsd.org Subject: Re: Implementation of the AGENT_STATE Register 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: Tue, 05 Feb 2008 04:20:43 -0000 I think you can send async. packets using fwmem_write_* functions. On Feb 5, 2008 8:21 AM, Sean Bruno wrote: > Hidetoshi: > > I'm attempting to implement the AGENT_STATE register in sbp_targ. > Somehow, I can't understand how to sent the agent state back to the > initiator. > > I am processing the request, but I am really unsure how to return the > state(what function calls?). > > Sean > > -- /\ Hidetoshi Shimokawa \/ simokawa@FreeBSD.ORG From owner-freebsd-firewire@FreeBSD.ORG Tue Feb 5 04:25:59 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 1357E16A417; Tue, 5 Feb 2008 04:25:59 +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 A2BC413C4F4; Tue, 5 Feb 2008 04:25:58 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 155CB61B927; Mon, 4 Feb 2008 20:25:58 -0800 (PST) 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 03414-03; Mon, 4 Feb 2008 20:25:53 -0800 (PST) Received: from [10.47.1.242] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id 9152B61B973; Mon, 4 Feb 2008 20:25:53 -0800 (PST) Message-ID: <47A7E550.7060500@miralink.com> Date: Mon, 04 Feb 2008 20:25:52 -0800 From: Sean Bruno User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Hidetoshi Shimokawa References: <47A79E13.5040706@miralink.com> <626eb4530802042020n78001c00kddbdedb907902691@mail.gmail.com> In-Reply-To: <626eb4530802042020n78001c00kddbdedb907902691@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-DSPAM-Result: Innocent X-DSPAM-Processed: Mon Feb 4 20:25:54 2008 X-DSPAM-Confidence: 0.9997 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 47a7e552233505260519334 X-DSPAM-Factors: 27, X-Virus-Scanned: amavisd-new at X-Spam-Status: No, score=-4.499 tagged_above=-10 required=6.6 autolearn=ham tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599, DSPAM_HAM=-0.1] X-Spam-Score: -4.499 X-Spam-Level: Cc: freebsd-firewire@freebsd.org Subject: Re: Implementation of the AGENT_STATE Register 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: Tue, 05 Feb 2008 04:25:59 -0000 Hidetoshi Shimokawa wrote: > I think you can send async. packets using fwmem_write_* functions. > > On Feb 5, 2008 8:21 AM, Sean Bruno wrote: > >> Hidetoshi: >> >> I'm attempting to implement the AGENT_STATE register in sbp_targ. >> Somehow, I can't understand how to sent the agent state back to the >> initiator. >> >> I am processing the request, but I am really unsure how to return the >> state(what function calls?). >> >> Sean >> >> >> > > > > I think I am confused by the specification. Where does the AGENT_STATE need to be written to? Sean From owner-freebsd-firewire@FreeBSD.ORG Tue Feb 5 04:43:25 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 DAEA616A417 for ; Tue, 5 Feb 2008 04:43:25 +0000 (UTC) (envelope-from freebsd@gm.nunu.org) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.241]) by mx1.freebsd.org (Postfix) with ESMTP id 9EEA613C455 for ; Tue, 5 Feb 2008 04:43:25 +0000 (UTC) (envelope-from freebsd@gm.nunu.org) Received: by an-out-0708.google.com with SMTP id c14so657219anc.13 for ; Mon, 04 Feb 2008 20:43:24 -0800 (PST) Received: by 10.100.128.20 with SMTP id a20mr16823170and.109.1202186604678; Mon, 04 Feb 2008 20:43:24 -0800 (PST) Received: by 10.100.247.18 with HTTP; Mon, 4 Feb 2008 20:43:24 -0800 (PST) Message-ID: <626eb4530802042043t3e0ce8d1l83f64b2d3ea48b1c@mail.gmail.com> Date: Tue, 5 Feb 2008 13:43:24 +0900 From: "Hidetoshi Shimokawa" Sender: freebsd@gm.nunu.org To: "Sean Bruno" In-Reply-To: <47A7E550.7060500@miralink.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <47A79E13.5040706@miralink.com> <626eb4530802042020n78001c00kddbdedb907902691@mail.gmail.com> <47A7E550.7060500@miralink.com> X-Google-Sender-Auth: acfbde129225cfcd Cc: freebsd-firewire@freebsd.org Subject: Re: Implementation of the AGENT_STATE Register 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: Tue, 05 Feb 2008 04:43:25 -0000 O.K. I checked the specification. AGENT_STATE is a register. So you have to respond with a read response packet rather than a write request packet. A response packet should be sent via fw_asyreq() with a tcode FWTCODE_RRES*. On Feb 5, 2008 1:25 PM, Sean Bruno wrote: > Hidetoshi Shimokawa wrote: > > I think you can send async. packets using fwmem_write_* functions. > > > > On Feb 5, 2008 8:21 AM, Sean Bruno wrote: > > > >> Hidetoshi: > >> > >> I'm attempting to implement the AGENT_STATE register in sbp_targ. > >> Somehow, I can't understand how to sent the agent state back to the > >> initiator. > >> > >> I am processing the request, but I am really unsure how to return the > >> state(what function calls?). > >> > >> Sean > >> > >> > >> > > > > > > > > > I think I am confused by the specification. Where does the AGENT_STATE > need to be written to? > > Sean > > -- /\ Hidetoshi Shimokawa \/ simokawa@FreeBSD.ORG From owner-freebsd-firewire@FreeBSD.ORG Wed Feb 6 20:09: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 60D6B16A417; Wed, 6 Feb 2008 20:09:33 +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 078B413C478; Wed, 6 Feb 2008 20:09:32 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id E164261B897; Wed, 6 Feb 2008 12:09:32 -0800 (PST) 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 28197-06; Wed, 6 Feb 2008 12:09:31 -0800 (PST) Received: from iago.office.miralink.com (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id 84D0961B891; Wed, 6 Feb 2008 12:09:31 -0800 (PST) Message-ID: <47AA13FB.4080209@miralink.com> Date: Wed, 06 Feb 2008 12:09:31 -0800 From: Sean Bruno User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Hidetoshi Shimokawa References: <47A79E13.5040706@miralink.com> <626eb4530802042020n78001c00kddbdedb907902691@mail.gmail.com> <47A7E550.7060500@miralink.com> <626eb4530802042043t3e0ce8d1l83f64b2d3ea48b1c@mail.gmail.com> In-Reply-To: <626eb4530802042043t3e0ce8d1l83f64b2d3ea48b1c@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-DSPAM-Result: Innocent X-DSPAM-Processed: Wed Feb 6 12:09:32 2008 X-DSPAM-Confidence: 0.9997 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 47aa13fc98653219765590 X-DSPAM-Factors: 27, X-Virus-Scanned: amavisd-new at X-Spam-Status: No, score=-4.499 tagged_above=-10 required=6.6 autolearn=ham tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599, DSPAM_HAM=-0.1] X-Spam-Score: -4.499 X-Spam-Level: Cc: freebsd-firewire@freebsd.org Subject: Re: Implementation of the AGENT_STATE Register 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, 06 Feb 2008 20:09:33 -0000 Hidetoshi Shimokawa wrote: > O.K. I checked the specification. > AGENT_STATE is a register. So you have to respond with a read response packet > rather than a write request packet. > A response packet should be sent via fw_asyreq() with a tcode FWTCODE_RRES*. > > Hmmm...This is what I have come up with. First I have defined an AGENT_STATE Structure as per SBP-2 6.4.1: struct agent_state { uint32_t fetch_agent_state; #define AGENT_STATE_RESET 0 #define AGENT_STATE_ACTIVE 1 #define AGENT_STATE_SUSPENDED 2 #define AGENT_STATE_DEAD 3 uint32_t bus_reset_command_reset_init_vals; uint32_t read_vals; uint32_t write_effects; } Second, I added a new function for the AGENT_STATE Register handler in sbp_targ_cmd(): case 0x00: /* AGENT_STATE */ printf("%s: AGENT_STATE (%d:ignore)\n", __func__, login_id); sbp_targ_send_agent_state(login); break; Third, I started coding sbp_targ_send_agent_state() to send the Read Response packet in addition to a call back handler to cleanup the malloc's after the read response is complete. I'm using code from firewire.c::fw_vmaccess() to guide myself, but I do not quite understand all of the pieces. Can you look at this code and tell me what it should look like as I'm pretty sure that it's wrong. static void sbp_targ_send_agent_state(struct login *login) { struct agent_state *current_state; struct fw_xfer *xfer; struct fw_pkt *sfp; struct fw_pkt *rfp; xfer = fw_xfer_alloc(M_SBP_TARG); current_state = malloc(sizeof(struct agent_state), M_SBP_TARG, M_NOWAIT | M_ZERO); current_state->fetch_agent_state = AGENT_STATE_ACTIVE; xfer->send.buf = current_state; xfer->send.len = sizeof(*current_state); xfer->send.spd = FWSPD_S400; sfp = (struct fw_pkt *)xfer->send.buf; rfp = (struct fw_pkt *)xfer->recv.buf; sfp->mode.rresq.data = *(uint32_t *)(ntohl(rfp->mode.rreqq.dest_lo)); sfp->mode.wres.tcode = FWTCODE_RRESB; sfp->mode.rresb.rtcode = 0; sfp->mode.hdr.dst = rfp->mode.hdr.src; xfer->dst = ntohs(rfp->mode.hdr.src); xfer->hand = sbp_targ_free_agent_state; sfp->mode.hdr.tlrt = rfp->mode.hdr.tlrt; sfp->mode.hdr.pri = 0; fw_asyreq(xfer->fc, -1, xfer); } static void sbp_targ_free_agent_state(struct fw_xfer *xfer) { if(xfer != NULL){ fw_xfer_free(xfer); } } Sean From owner-freebsd-firewire@FreeBSD.ORG Wed Feb 6 20:45:47 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 F27F516A418; Wed, 6 Feb 2008 20:45:46 +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 8FB4C13C47E; Wed, 6 Feb 2008 20:45:46 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 5C3E461B891; Wed, 6 Feb 2008 12:45:46 -0800 (PST) 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 01901-09; Wed, 6 Feb 2008 12:45:44 -0800 (PST) Received: from iago.office.miralink.com (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id AD55661B86B; Wed, 6 Feb 2008 12:45:44 -0800 (PST) Message-ID: <47AA1C78.1080305@miralink.com> Date: Wed, 06 Feb 2008 12:45:44 -0800 From: Sean Bruno User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Hidetoshi Shimokawa References: <47A79E13.5040706@miralink.com> <626eb4530802042020n78001c00kddbdedb907902691@mail.gmail.com> <47A7E550.7060500@miralink.com> <626eb4530802042043t3e0ce8d1l83f64b2d3ea48b1c@mail.gmail.com> <47AA13FB.4080209@miralink.com> In-Reply-To: <47AA13FB.4080209@miralink.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-DSPAM-Result: Innocent X-DSPAM-Processed: Wed Feb 6 12:45:46 2008 X-DSPAM-Confidence: 0.7829 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 47aa1c79312753377160525 X-DSPAM-Factors: 27, X-Virus-Scanned: amavisd-new at X-Spam-Status: No, score=-4.499 tagged_above=-10 required=6.6 autolearn=ham tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599, DSPAM_HAM=-0.1] X-Spam-Score: -4.499 X-Spam-Level: Cc: freebsd-firewire@freebsd.org Subject: Re: Implementation of the AGENT_STATE Register 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, 06 Feb 2008 20:45:47 -0000 Ok, perhaps I should _READ_ the code before I start writing! :) Please throw away my previous message. I have updated the function sbp_targ_send_agent_state(). The custom delete function is gone(just use fw_xfer_free_buf() ). I think this is much closer. Or, I just don't understand what I am doing(very likely!). Also, I pass the xfer struct into the function, not the login struct. I believe this is more correct? static void sbp_targ_send_agent_state(struct fw_xfer *xfer) { struct agent_state *current_state; struct fw_pkt *rfp; xfer->send_buf = malloc(sizeof(struct agent_state), M_SBP_TARG, M_NOWAIT | M_ZERO); xfer->send_len = ntohs(sizeof(struct agent_state)); current_state = (struct agent_state *)xfer->send_buf; current_state->fetch_agent_state = AGENT_STATE_ACTIVE; rfp = &xfer->recv.hdr; rfp->mode.rresb.payload = current_state; rfp->mode.rresb.tcode = FWTCODE_RRESB; rfp->mode.rresb.rtcode = 0; rfp->mode.rresb.extcode = 0; xfer->dst = ntohs(rfp->mode.hdr.src); xfer->hand = fw_xfer_free_buf; rfp->mode.hdr.pri = 0; fw_asyreq(xfer->fc, -1, xfer); } Sean Bruno wrote: > Hidetoshi Shimokawa wrote: >> O.K. I checked the specification. >> AGENT_STATE is a register. So you have to respond with a read >> response packet >> rather than a write request packet. >> A response packet should be sent via fw_asyreq() with a tcode >> FWTCODE_RRES*. >> >> > Hmmm...This is what I have come up with. > First I have defined an AGENT_STATE Structure as per SBP-2 6.4.1: > > struct agent_state { > uint32_t fetch_agent_state; > #define AGENT_STATE_RESET 0 > #define AGENT_STATE_ACTIVE 1 > #define AGENT_STATE_SUSPENDED 2 > #define AGENT_STATE_DEAD 3 > uint32_t bus_reset_command_reset_init_vals; > uint32_t read_vals; > uint32_t write_effects; > } > > > Second, I added a new function for the AGENT_STATE Register handler in > sbp_targ_cmd(): > case 0x00: /* AGENT_STATE */ > printf("%s: AGENT_STATE (%d:ignore)\n", __func__, > login_id); > sbp_targ_send_agent_state(login); > break; > > > Third, I started coding sbp_targ_send_agent_state() to send the Read > Response packet in addition to a call back handler to cleanup the > malloc's after the read response is complete. I'm using code from > firewire.c::fw_vmaccess() to guide myself, but I do not quite > understand all of the pieces. Can you look at this code and tell me > what it should look like as I'm pretty sure that it's wrong. > > static void > sbp_targ_send_agent_state(struct login *login) > { > struct agent_state *current_state; > struct fw_xfer *xfer; > struct fw_pkt *sfp; > struct fw_pkt *rfp; > > xfer = fw_xfer_alloc(M_SBP_TARG); > current_state = malloc(sizeof(struct agent_state), M_SBP_TARG, > M_NOWAIT | M_ZERO); > current_state->fetch_agent_state = AGENT_STATE_ACTIVE; > xfer->send.buf = current_state; > xfer->send.len = sizeof(*current_state); > xfer->send.spd = FWSPD_S400; > > sfp = (struct fw_pkt *)xfer->send.buf; > rfp = (struct fw_pkt *)xfer->recv.buf; > sfp->mode.rresq.data = *(uint32_t > *)(ntohl(rfp->mode.rreqq.dest_lo)); > sfp->mode.wres.tcode = FWTCODE_RRESB; > sfp->mode.rresb.rtcode = 0; > sfp->mode.hdr.dst = rfp->mode.hdr.src; > xfer->dst = ntohs(rfp->mode.hdr.src); > xfer->hand = sbp_targ_free_agent_state; > sfp->mode.hdr.tlrt = rfp->mode.hdr.tlrt; > sfp->mode.hdr.pri = 0; > fw_asyreq(xfer->fc, -1, xfer); > > } > > static void > sbp_targ_free_agent_state(struct fw_xfer *xfer) > { > if(xfer != NULL){ > fw_xfer_free(xfer); > } > > } > > Sean > _______________________________________________ > freebsd-firewire@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-firewire > To unsubscribe, send any mail to > "freebsd-firewire-unsubscribe@freebsd.org" From owner-freebsd-firewire@FreeBSD.ORG Fri Feb 8 21:06:21 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 C2DD416A417; Fri, 8 Feb 2008 21:06:21 +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 8F87713C457; Fri, 8 Feb 2008 21:06:21 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 1D6E261B853; Fri, 8 Feb 2008 13:06:21 -0800 (PST) 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 01245-05; Fri, 8 Feb 2008 13:06:19 -0800 (PST) Received: from iago.office.miralink.com (iago.office.miralink.com [10.0.0.40]) by plato.miralink.com (Postfix) with ESMTP id BBFF061B3BE; Fri, 8 Feb 2008 13:06:19 -0800 (PST) Message-ID: <47ACC44B.9090504@miralink.com> Date: Fri, 08 Feb 2008 13:06:19 -0800 From: Sean Bruno User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Hidetoshi Shimokawa References: <47A79E13.5040706@miralink.com> <626eb4530802042020n78001c00kddbdedb907902691@mail.gmail.com> <47A7E550.7060500@miralink.com> <626eb4530802042043t3e0ce8d1l83f64b2d3ea48b1c@mail.gmail.com> <47AA13FB.4080209@miralink.com> <47AA1C78.1080305@miralink.com> In-Reply-To: <47AA1C78.1080305@miralink.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-DSPAM-Result: Innocent X-DSPAM-Processed: Fri Feb 8 13:06:20 2008 X-DSPAM-Confidence: 0.9997 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 47acc44c226427852419847 X-DSPAM-Factors: 27, X-Virus-Scanned: amavisd-new at X-Spam-Status: No, score=-4.499 tagged_above=-10 required=6.6 autolearn=ham tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599, DSPAM_HAM=-0.1] X-Spam-Score: -4.499 X-Spam-Level: Cc: freebsd-firewire@freebsd.org Subject: Re: Implementation of the AGENT_STATE Register 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, 08 Feb 2008 21:06:21 -0000 Hidetoshi: Can you review this and correct it where needed? I am sure that it is wrong, but I haven't tested it yet. struct agent_state { uint32_t fetch_agent_state; #define AGENT_STATE_RESET 0 #define AGENT_STATE_ACTIVE 1 #define AGENT_STATE_SUSPENDED 2 #define AGENT_STATE_DEAD 3 uint32_t bus_reset_command_reset_init_vals; uint32_t read_vals; uint32_t write_effects; }; static void sbp_targ_send_agent_state(struct fw_xfer *xfer) { struct agent_state *current_state; struct fw_pkt *rfp; /* response to request --> from target */ xfer->send.payload = malloc(sizeof(struct agent_state), M_SBP_TARG, M_NOWAIT | M_ZERO); xfer->send.pay_len = ntohs(sizeof(struct agent_state)); xfer->send.spd = FWSPD_S400; current_state = (struct agent_state *)xfer->send.payload; current_state->fetch_agent_state = AGENT_STATE_ACTIVE; rfp = &xfer->recv.hdr; rfp->mode.rresb.tcode = FWTCODE_RRESB; rfp->mode.rresb.rtcode = 0; rfp->mode.rresb.extcode = 0; xfer->send.hdr.mode.hdr.dst = ntohs(rfp->mode.hdr.src); xfer->hand = fw_xfer_free_buf; rfp->mode.hdr.pri = 0; fw_asyreq(xfer->fc, -1, xfer); } Sean