~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/scsi/libfc/fc_lport.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 * while making the callback. To ensure that the rport is not free'd while
53
53
 * processing the callback the rport callbacks are serialized through a
54
54
 * single-threaded workqueue. An rport would never be free'd while in a
55
 
 * callback handler becuase no other rport work in this queue can be executed
 
55
 * callback handler because no other rport work in this queue can be executed
56
56
 * at the same time.
57
57
 *
58
58
 * When discovery succeeds or fails a callback is made to the lport as
163
163
 * fc_lport_rport_callback() - Event handler for rport events
164
164
 * @lport: The lport which is receiving the event
165
165
 * @rdata: private remote port data
166
 
 * @event: The event that occured
 
166
 * @event: The event that occurred
167
167
 *
168
168
 * Locking Note: The rport lock should not be held when calling
169
169
 *               this function.
379
379
 
380
380
/**
381
381
 * fc_lport_recv_rlir_req() - Handle received Registered Link Incident Report.
382
 
 * @lport: Fibre Channel local port recieving the RLIR
 
382
 * @lport: Fibre Channel local port receiving the RLIR
383
383
 * @fp:    The RLIR request frame
384
384
 *
385
385
 * Locking Note: The lport lock is expected to be held before calling
396
396
 
397
397
/**
398
398
 * fc_lport_recv_echo_req() - Handle received ECHO request
399
 
 * @lport: The local port recieving the ECHO
 
399
 * @lport: The local port receiving the ECHO
400
400
 * @fp:    ECHO request frame
401
401
 *
402
402
 * Locking Note: The lport lock is expected to be held before calling
432
432
 
433
433
/**
434
434
 * fc_lport_recv_rnid_req() - Handle received Request Node ID data request
435
 
 * @lport: The local port recieving the RNID
 
435
 * @lport: The local port receiving the RNID
436
436
 * @fp:    The RNID request frame
437
437
 *
438
438
 * Locking Note: The lport lock is expected to be held before calling
491
491
 
492
492
/**
493
493
 * fc_lport_recv_logo_req() - Handle received fabric LOGO request
494
 
 * @lport: The local port recieving the LOGO
 
494
 * @lport: The local port receiving the LOGO
495
495
 * @fp:    The LOGO request frame
496
496
 *
497
497
 * Locking Note: The lport lock is exected to be held before calling
633
633
        lport->tt.fcp_abort_io(lport);
634
634
        lport->tt.disc_stop_final(lport);
635
635
        lport->tt.exch_mgr_reset(lport, 0, 0);
 
636
        fc_fc4_del_lport(lport);
636
637
        return 0;
637
638
}
638
639
EXPORT_SYMBOL(fc_lport_destroy);
770
771
 
771
772
/**
772
773
 * fc_lport_recv_flogi_req() - Receive a FLOGI request
773
 
 * @lport: The local port that recieved the request
 
774
 * @lport: The local port that received the request
774
775
 * @rx_fp: The FLOGI frame
775
776
 *
776
777
 * A received FLOGI request indicates a point-to-point connection.
849
850
}
850
851
 
851
852
/**
852
 
 * fc_lport_recv_req() - The generic lport request handler
 
853
 * fc_lport_recv_els_req() - The generic lport ELS request handler
853
854
 * @lport: The local port that received the request
854
855
 * @fp:    The request frame
855
856
 *
857
858
 * if an rport should handle the request.
858
859
 *
859
860
 * Locking Note: This function should not be called with the lport
860
 
 *               lock held becuase it will grab the lock.
 
861
 *               lock held because it will grab the lock.
861
862
 */
862
 
static void fc_lport_recv_req(struct fc_lport *lport, struct fc_frame *fp)
 
863
static void fc_lport_recv_els_req(struct fc_lport *lport,
 
864
                                  struct fc_frame *fp)
863
865
{
864
 
        struct fc_frame_header *fh = fc_frame_header_get(fp);
865
866
        void (*recv)(struct fc_lport *, struct fc_frame *);
866
867
 
867
868
        mutex_lock(&lport->lp_mutex);
873
874
         */
874
875
        if (!lport->link_up)
875
876
                fc_frame_free(fp);
876
 
        else if (fh->fh_type == FC_TYPE_ELS &&
877
 
                 fh->fh_r_ctl == FC_RCTL_ELS_REQ) {
 
877
        else {
878
878
                /*
879
879
                 * Check opcode.
880
880
                 */
903
903
                }
904
904
 
905
905
                recv(lport, fp);
906
 
        } else {
907
 
                FC_LPORT_DBG(lport, "dropping invalid frame (eof %x)\n",
908
 
                             fr_eof(fp));
909
 
                fc_frame_free(fp);
910
906
        }
911
907
        mutex_unlock(&lport->lp_mutex);
912
908
}
913
909
 
 
910
static int fc_lport_els_prli(struct fc_rport_priv *rdata, u32 spp_len,
 
911
                             const struct fc_els_spp *spp_in,
 
912
                             struct fc_els_spp *spp_out)
 
913
{
 
914
        return FC_SPP_RESP_INVL;
 
915
}
 
916
 
 
917
struct fc4_prov fc_lport_els_prov = {
 
918
        .prli = fc_lport_els_prli,
 
919
        .recv = fc_lport_recv_els_req,
 
920
};
 
921
 
 
922
/**
 
923
 * fc_lport_recv_req() - The generic lport request handler
 
924
 * @lport: The lport that received the request
 
925
 * @fp: The frame the request is in
 
926
 *
 
927
 * Locking Note: This function should not be called with the lport
 
928
 *               lock held because it may grab the lock.
 
929
 */
 
930
static void fc_lport_recv_req(struct fc_lport *lport,
 
931
                              struct fc_frame *fp)
 
932
{
 
933
        struct fc_frame_header *fh = fc_frame_header_get(fp);
 
934
        struct fc_seq *sp = fr_seq(fp);
 
935
        struct fc4_prov *prov;
 
936
 
 
937
        /*
 
938
         * Use RCU read lock and module_lock to be sure module doesn't
 
939
         * deregister and get unloaded while we're calling it.
 
940
         * try_module_get() is inlined and accepts a NULL parameter.
 
941
         * Only ELSes and FCP target ops should come through here.
 
942
         * The locking is unfortunate, and a better scheme is being sought.
 
943
         */
 
944
 
 
945
        rcu_read_lock();
 
946
        if (fh->fh_type >= FC_FC4_PROV_SIZE)
 
947
                goto drop;
 
948
        prov = rcu_dereference(fc_passive_prov[fh->fh_type]);
 
949
        if (!prov || !try_module_get(prov->module))
 
950
                goto drop;
 
951
        rcu_read_unlock();
 
952
        prov->recv(lport, fp);
 
953
        module_put(prov->module);
 
954
        return;
 
955
drop:
 
956
        rcu_read_unlock();
 
957
        FC_LPORT_DBG(lport, "dropping unexpected frame type %x\n", fh->fh_type);
 
958
        fc_frame_free(fp);
 
959
        lport->tt.exch_done(sp);
 
960
}
 
961
 
914
962
/**
915
963
 * fc_lport_reset() - Reset a local port
916
964
 * @lport: The local port which should be reset
1549
1597
 
1550
1598
        fc_lport_add_fc4_type(lport, FC_TYPE_FCP);
1551
1599
        fc_lport_add_fc4_type(lport, FC_TYPE_CT);
 
1600
        fc_fc4_conf_lport_params(lport, FC_TYPE_FCP);
1552
1601
 
1553
1602
        return 0;
1554
1603
}
1586
1635
                fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_1GBIT;
1587
1636
        if (lport->link_supported_speeds & FC_PORTSPEED_10GBIT)
1588
1637
                fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_10GBIT;
 
1638
        fc_fc4_add_lport(lport);
1589
1639
 
1590
1640
        return 0;
1591
1641
}