03 Oct, 2011

2 commits

  • cache aligned xid and ex_lock beside
    removing holes.

    Signed-off-by: Vasu Dev
    Tested-by: Ross Brattain
    Signed-off-by: Yi Zou
    Signed-off-by: James Bottomley

    Vasu Dev
     
  • Re-arrange its fields to avoid padding and have better
    cacheline alignments.

    Removed not used start_time, end_time and last_pkt_time
    fields.

    This all reduced this struct size to 448 from 480 and
    that also reduced one cacheline on x86_64 beside
    eliminating 8 pads. However kept logical fields together.

    Signed-off-by: Vasu Dev
    Tested-by: Ross Brattain
    Signed-off-by: Yi Zou
    Signed-off-by: James Bottomley

    Vasu Dev
     

30 Jun, 2011

1 commit

  • The fcoe driver can implement ddp_targ() similarly to ddp_setup() when fcoe
    stack works with existing target frame, e.g., tcm, where the ddp_targ() would
    eventually point to the underlying hardware driver's implementation of
    ndo_fcoe_ddp_targ() through net_device_ops. This new API sets up DDP context
    for target appropriately by setting required bits for DDP context.

    Signed-off-by: Yi Zou
    Signed-off-by: Kiran Patil
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Yi Zou
     

31 Mar, 2011

1 commit


13 Feb, 2011

6 commits

  • This patch enables LLD to listen to rport events and perform LLD
    specific operations based on the rport event. This patch also stores
    sp_features and spp_type in rdata for further reference by LLD.

    Signed-off-by: Bhanu Prakash Gollapudi
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Bhanu Prakash Gollapudi
     
  • Target modules using lport->tt.seq_assign() get a hold on the
    exchange but have no way of releasing it. Add that.

    Signed-off-by: Joe Eykholt
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • When an SCST provider is registered, it needs to know what
    local ports are available for configuration as targets.

    Add a notifier chain that is invoked when any local port
    that is added or deleted.

    Maintain a global list of local ports and add an
    interator function that calls a given function for
    every existing local port. This is used when first
    loading a provider.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • The target provider needs a per-instance lookup table
    or other way to lookup sessions quickly without going through
    a linear list or serializing too much.

    Add a simple void * array indexed by FC-4 type to the fc_lport.

    Signed-off-by: Joe Eykholt
    Committed-by: Nicholas A. Bellinger
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • Add a method for setting handler for incoming exchange.
    For multi-sequence exchanges, this allows the target driver
    to add a response handler for handling subsequent sequences,
    and exchange manager resets.

    The new function is called fc_seq_set_resp().

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • Allow FC-4 provider modules to hook into libfc, mostly for targets.
    This should allow any FC-4 module to handle PRLI requests and maintain
    process-association states.

    Each provider registers its ops with libfc and then will be called for
    any incoming PRLI for that FC-4 type on any instance. The provider
    can decide whether to handle that particular instance using any method
    it likes, such as ACLs or other configuration information.

    A count is kept of the number of successful PRLIs from the remote port.
    Providers are called back with an implicit PRLO when the remote port
    is about to be deleted or has been reset.

    fc_lport_recv_req() now sends incoming FC-4 requests to FC-4 providers,
    and there is a built-in provider always registered for handling
    incoming ELS requests.

    The call to provider recv() routines uses rcu_read_lock()
    so that providers aren't removed during the call. That lock is very
    cheap and shouldn't affect any performance on ELS requests.
    Providers can rely on the RCU lock to protect a session lookup as well.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     

22 Dec, 2010

2 commits

  • The statistics for InputMegabytes and OutputMegabytes are
    misnamed. They're accumulating bytes, not megabytes.

    The statistic returned via /sys must be in megabytes, however,
    which is what the HBA-API wants. The FCP code needs to accumulate
    it in bytes and then divide by 1,000,000 (not 2^20) before it
    presented via sysfs.

    This affects fcoe.ko only, not fnic. The fnic driver
    correctly by accumulating bytes and then converts to megabytes.

    I checked that libhbalinux is using the /sys file directly without
    conversion.

    BTW, qla2xxx does divide by 2^20, which I'm not fixing here.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • We can easily remove the tgt_flags from fc_fcp_pkt struct
    and use rpriv->tgt_flags directly where needed.

    Signed-off-by: John Fastabend
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    john fastabend
     

17 Nov, 2010

1 commit

  • Move the mid-layer's ->queuecommand() invocation from being locked
    with the host lock to being unlocked to facilitate speeding up the
    critical path for drivers who don't need this lock taken anyway.

    The patch below presents a simple SCSI host lock push-down as an
    equivalent transformation. No locking or other behavior should change
    with this patch. All existing bugs and locking orders are preserved.

    Additionally, add one parameter to queuecommand,
    struct Scsi_Host *
    and remove one parameter from queuecommand,
    void (*done)(struct scsi_cmnd *)

    Scsi_Host* is a convenient pointer that most host drivers need anyway,
    and 'done' is redundant to struct scsi_cmnd->scsi_done.

    Minimal code disturbance was attempted with this change. Most drivers
    needed only two one-line modifications for their host lock push-down.

    Signed-off-by: Jeff Garzik
    Acked-by: James Bottomley
    Signed-off-by: Linus Torvalds

    Jeff Garzik
     

26 Oct, 2010

1 commit

  • When number of NPIV ports created are greater than the xids
    allocated per pool -- for eg., creating 255 NPIV ports on a
    system with nr_cpu_ids of 32, with each pool containing 128
    xids -- and then generating a link event - for eg.,
    shutdown/no shutdown -- on the switch port causes the hang
    with the following stack trace.

    Call Trace:
    schedule_timeout+0x19d/0x230
    wait_for_common+0xc0/0x170
    __cancel_work_timer+0xcf/0x1b0
    fc_disc_stop+0x16/0x30 [libfc]
    fc_lport_reset_locked+0x47/0x90 [libfc]
    fc_lport_enter_reset+0x67/0xe0 [libfc]
    fc_lport_disc_callback+0xbc/0xe0 [libfc]
    fc_disc_done+0xa8/0xf0 [libfc]
    fc_disc_timeout+0x29/0x40 [libfc]
    run_workqueue+0xb8/0x140
    worker_thread+0x96/0x110
    kthread+0x96/0xa0
    child_rip+0xa/0x20

    Fix is to not cancel the disc_work if discovery is already
    stopped, thus allowing lport state machine to restart and try
    discovery again.

    Signed-off-by: Bhanu Prakash Gollapudi
    Acked-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Bhanu Prakash Gollapudi
     

28 Jul, 2010

13 commits

  • Incoming requests shouldn't require a local exchange if we're
    just going to reply with one or two frames and don't expect
    anything further. Don't allocate exchanges for such requests
    until requested by the upper-layer protocol.

    The sequence is always NULL for new requests, so remove
    that as an argument to request handlers.

    Also change the first argument to lport->tt.seq_els_rsp_send
    from the sequence pointer to the received frame pointer, to
    supply the exchange IDs and destination ID info.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • For incoming ELS and FCP requests, we often don't require an
    exchange and sequence, however, sometimes we do. For those cases,
    (primarily FCP requests for targets) add a function to set up
    the exchange and sequence.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • Add functions to fill in an FC header given a request header.
    These reduces code lines in fc_lport and fc_rport and works
    without an exchange/sequence assigned.

    fc_fill_reply_hdr() fills a header for a final reply frame.

    fc_fill_hdr() which is similar but allows specifying the
    f_ctl parameter.

    Add defines for F_CTL values FC_FCTL_REQ and FC_FCTL_RESP.
    These can be used for most request and response sequences.

    v2 of patch adds a line to copy the frame encapsulation
    info from the received frame.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • To pave the way for eliminating exchanges from incoming requests,
    add simple inline fc_frame_sid() and fc_frame_did() functions
    which get the FC_IDs from the frame header. This can be almost
    as efficient as getting them from the sequence/exchange.

    Move ntohll, htonll, ntoh24 and hton24 to
    since we need them there and that's included by

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • The LOGO state hasn't been used in a while, except in a brief
    transition to DELETE state while holding the rport mutex.
    All port LOGO responses have been ignored as well as any timeout
    if we don't get a response.

    So this patch just removes LOGO state and simplifies the response handler.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • When an exchange is received with a FIP encapsulation, we need
    to know that the response must be sent via FIP and what the original
    ELS opcode was. This becomes important for VN2VN mode, where we may
    receive FLOGI or LOGO from several peer VN_ports, and the LS_ACC or
    LS_RJT must be sent FIP-encapsulated with the correct sub-type.

    Add a field to the struct fc_frame, fr_encaps, to indicate the
    encapsulation values. That term is chosen to be neutral and
    LLD-agnostic in case non-FCoE/FIP LLDs might find it useful.

    The frame fr_encaps is transferred from the ingress frame to the
    exchange by fc_exch_recv_req(), and back to the outgoing frame
    by fc_seq_send().

    This is taking the last byte in the skb->cb array. If needed,
    we could combine the info in sof, eof, flags, and encaps
    together into one field, but it'd be better to do that if
    and when its needed.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • The FIP proposal for VN_port to VN_port point-to-multipoint
    operation requires a FLOGI be sent to each remote port.
    The FLOGI is sent with the assigned S_ID and D_IDs of the
    local and remote ports. This and the response get
    FIP-encapsulated for Ethernet.

    Add FLOGI state to the remote port state machine.
    This will be skipped if not in point-to-multipoint mode.

    To reduce a little duplication between PLOGI and FLOGI
    response handling, added fc_rport_login_complete(), which
    handles the parameters for the rdata struct.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • For VN_port to VN_port mode, the transport sets the port_id and
    there's no lport FLOGI. This is similar to FC loop mode.

    Add a point_to_multipoint flag that indicates the local port is in
    point-to-multipoint mode. This skips FLOGI and discovery.
    It also skips resetting the port_id on resets other than link down.

    Add function fc_lport_set_local_id() that sets the local port_id.
    This is called by libfcoe on behalf of the low-level driver
    to set the port_id when the link comes up.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • For VN_port to VN_port mode, FIP will do discovery and needs a
    way to find its state from the local port or discovery structure.
    It seems that any other LLD that implements its own discovery
    would also need something like this.

    Replace disc->lport with disc->priv, and use container_of to
    find the lport. We could use disc->priv for that, but
    container_of is smaller and faster.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • Add pre-zeroed space after the allocation for fc_rport_priv
    for use by the lower-level driver.

    This is primarily for VN2VN FIP mode, but could be used in
    other ways someday.

    The space required is specified in lport->rport_priv_size.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • To allow LLD to do lookups on rports without grabbing a mutex,
    make them RCU-safe. The caller of lport->tt.rport_lookup will
    have the choice of holding disc_mutex or the rcu_read_lock().

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • Remote ports were restarting indefinitely after getting
    rejects in PRLI.

    Fix by adding a counter of restarts and limiting that with
    the port login retry limit as well.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • This patch somewhat combines two fixes to remote port handing in libfc.

    The first problem was that rport work could be queued on a deleted
    and freed rport. This is handled by not resetting rdata->event
    ton NONE if the rdata is about to be deleted.

    However, that fix led to the second problem, described by
    Bhanu Gollapudi, as follows:
    > Here is the sequence of events. T1 is first LOGO receive thread, T2 is
    > fc_rport_work() scheduled by T1 and T3 is second LOGO receive thread and
    > T4 is fc_rport_work scheduled by T3.
    >
    > 1. (T1)Received 1st LOGO in state Ready
    > 2. (T1)Delete port & enter to RESTART state.
    > 3. (T1)schdule event_work, since event is RPORT_EV_NONE.
    > 4. (T1)set event = RPORT_EV_LOGO
    > 5. (T1)Enter RESTART state as disc_id is set.
    > 6. (T2)remember to PLOGI, and set event = RPORT_EV_NONE
    > 6. (T3)Received 2nd LOGO
    > 7. (T3)Delete Port & enter to RESTART state.
    > 8. (T3)schedule event_work, since event is RPORT_EV_NONE.
    > 9. (T3)Enter RESTART state as disc_id is set.
    > 9. (T3)set event = RPORT_EV_LOGO
    > 10.(T2)work restart, enter PLOGI state and issues PLOGI
    > 11.(T4)Since state is not RESTART anymore, restart is not set, and the
    > event is not reset to RPORT_EV_NONE. (current event is RPORT_EV_LOGO).
    > 12. Now, PLOGI succeeds and fc_rport_enter_ready() will not schedule
    > event_work, and hence the rport will never be created, eventually losing
    > the target after dev_loss_tmo.

    So, the problem here is that we were tracking the desire for
    the rport be restarted by state RESTART, which was otherwise
    equivalent to DELETE. A contributing factor is that we dropped
    the lock between steps 6 and 10 in thread T2, which allows the
    state to change, and we didn't completely re-evaluate then.

    This is hopefully corrected by the following minor redesign:

    Simplify the rport restart logic by making the decision to
    restart after deleting the transport rport. That decision
    is based on a new STARTED flag that indicates fc_rport_login()
    has been called and fc_rport_logoff() has not been called
    since then. This replaces the need for the RESTART state.

    Only restart if the rdata is still in DELETED state
    and only if it still has the STARTED flag set.

    Also now, since we clear the event code much later in the
    work thread, allow for the possibility that the rport may
    have become READY again via incoming PLOGI, and if so,
    queue another event to handle that.

    In the problem scenario, the second LOGO received will
    cause the LOGO event to occur again.

    Reported-by: Bhanu Gollapudi
    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     

17 May, 2010

2 commits

  • This patch creates a port_id member in struct fc_lport.
    This allows libfc to just deal with fc_lport instances
    instead of calling into the fc_host to get the port_id.

    This change helps in only using symbols necessary for
    operation from the libfc structures. libfc still needs
    to change the fc_host_port_id() if the port_id changes
    so the presentation layer (scsi_transport_fc) can provide
    the user with the correct value, but libfc shouldn't
    rely on the presentation layer for operational values.

    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Robert Love
     
  • Remove this unused routine.

    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Robert Love
     

12 Apr, 2010

1 commit


11 Apr, 2010

1 commit

  • When the kernel is configured for preemption, using smp_processor_id()
    when preemption is enabled causes a warning backtrace and is wrong
    since we could move off of that CPU as soon as we get the ID,
    and we would be referencing the wrong CPU, and possibly an invalid one
    if it could be hotswapped out.

    Remove the fc_lport_get_stats() function and explicitly use per_cpu_ptr()
    to get the statistics. Where preemption has been disabled by holding
    a _bh lock continue to use smp_processor_id(), but otherwise use
    get_cpu()/put_cpu().

    In fcoe_recv_frame() also changed the cases where we return in the
    middle to do a goto to the code which bumps ErrorFrames and does
    a put_cpu(). Two of these cases didn't bump ErrorFrames before, but
    doing so is harmless because they "can't happen", due to prior length
    checks.

    Also rearranged code in fcoe_recv_frame() to have only one call to
    fc_exch_recv(). It's just as efficient and saves a call to put_cpu().

    In fc_fcp.c, adjusted a FIXME comment for code which doesn't need fixing.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     

05 Dec, 2009

9 commits

  • Add a member function pointer as get_lesb to libfc_function_template so LLD
    can fill the LESB based on its own statistics. For fcoe, it fills the LESB
    as a fcoe_fc_els_lesb struct according to FC-BB-5.

    Signed-off-by: Yi Zou
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Yi Zou
     
  • FC-BB-5 Rev2.0, Clause 7.10 extends the FC-LS-3 LESB for FC-BB_E. We are
    already tracking Link Failure Count so add the rest in this patch.

    For VLinkFailureCount and MissDiscAdvCount, they are part of the per-cpu
    fcoe_dev_stats. For SymbolErrorCount, ErroredBlockCount, and FCSErrorCount,
    they are defined in IEEE 802.3-2008 and are per LLD. They are expected to
    come from LLD.

    Signed-off-by: Yi Zou
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Yi Zou
     
  • Customers and certification tests have pointed out that we don't
    show up on the switch management software as an initiator.

    On some MDS switches 'show fcns database' command shows libfc
    initiators as 'fcp' not 'fcp:init' like other initiators.

    On others switches, I think the switch gets the features by doing a PRLI,
    but it may be only certain models or under certain configurations.

    Fix this by registering our FC4 features with the RFF_ID CT request
    after local port login and after the RFT_ID.

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • This is to notify the LLD when an FC_ID is assigned to the local port.

    The fnic driver needs to push the assigned FC_ID to firmware.
    It currently does this by intercepting the FLOGI responses, and
    in order to make that code more common with FIP and NPIV, it
    makes more sense to wait until the local port has completely
    handled the FLOGI or FDISC response. Also, when we fix
    point-to-point FC_ID assignment, we'll need this callback as well.

    Add a call to the libfc template, which is called whenever
    the local port FC_ID is being assigned. It defaults to
    fc_lport_set_fid(), supplied by libfc.

    As additional benefit of this function, the LLD may determine
    the MAC address that caused the change by looking at the received frame.

    We also print the assigned port ID as long as it isn't 0.
    Setting port ID to 0 happens often in reset while retrying FLOGI,
    and would be uninteresting. This replaces the previous message
    which didn't identify the host adapter instance.

    patch v2 note: changed one word in a comment. "intercepted" -> "provided".

    Signed-off-by: Joe Eykholt
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Joe Eykholt
     
  • This patch makes a variety of cleanup changes to all libfc files.

    This patch adds kernel-doc headers to all functions lacking them
    and attempts to better format existing headers. It also add kernel-doc
    headers to structures.

    This patch ensures that the current naming conventions for local ports,
    remote ports and remote port private data is upheld in the following
    manner.

    struct instance (i.e. variable name)
    --------------------------------------------------
    fc_lport lport
    fc_rport rport
    fc_rport_libfc_priv rpriv
    fc_rport_priv rdata

    I also renamed dns_rp and ptp_rp to dns_rdata and ptp_rdata
    respectively.

    I used emacs 'indent-region' and 'tabify' on all libfc files
    to correct spacing alignments.

    I feel sorry for anyone attempting to review this patch.

    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Robert Love
     
  • This is the Open-FCoE implementation of the FC
    passthrough support via bsg interface.

    Passthrough support is added to both N_Ports and
    VN_Ports.

    Signed-off-by: Steve Ma
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Steve Ma
     
  • Register the fc_host symbolic name as the symbolic port name
    with the fabric name server.

    Signed-off-by: Chris Leech
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Chris Leech
     
  • Register the fc_host symbolic name as the symbolic node name
    with the fabric name server.

    Signed-off-by: Chris Leech
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Chris Leech
     
  • One could interpret FC-GS-5 to say that an explicit RNN_ID is required
    before RSNN_NN is allowed to succeed, which is why RNN_ID was not obsoleted
    along with RPN_ID acording to this document:
    ftp://ftp.t11.org/t11/member/fc/gs-5/05-546v2.pdf

    Signed-off-by: Chris Leech
    Signed-off-by: Robert Love
    Signed-off-by: James Bottomley

    Chris Leech