diff options
author | Joe Eykholt <jeykholt@cisco.com> | 2010-07-20 18:20:56 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-28 10:05:59 -0400 |
commit | 251748a99e631a2c46edcf9e519cfc60fae8153d (patch) | |
tree | 6255e513473fffde4691f761c53e82440d763d18 /drivers | |
parent | 079ecd8cfe95dfd28b74f3a00d66fdbcdfc8c611 (diff) |
[SCSI] libfc: add fc_frame_sid() and fc_frame_did() functions
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 <scsi/fc_frame.h>
since we need them there and that's included by <scsi/libfc.h>
Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/libfc/fc_lport.c | 12 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_rport.c | 26 |
2 files changed, 10 insertions, 28 deletions
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index ec9850c46170..be3c2cee829f 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c | |||
@@ -800,7 +800,6 @@ static void fc_lport_recv_flogi_req(struct fc_seq *sp_in, | |||
800 | struct fc_lport *lport) | 800 | struct fc_lport *lport) |
801 | { | 801 | { |
802 | struct fc_frame *fp; | 802 | struct fc_frame *fp; |
803 | struct fc_frame_header *fh; | ||
804 | struct fc_seq *sp; | 803 | struct fc_seq *sp; |
805 | struct fc_exch *ep; | 804 | struct fc_exch *ep; |
806 | struct fc_els_flogi *flp; | 805 | struct fc_els_flogi *flp; |
@@ -813,8 +812,7 @@ static void fc_lport_recv_flogi_req(struct fc_seq *sp_in, | |||
813 | FC_LPORT_DBG(lport, "Received FLOGI request while in state %s\n", | 812 | FC_LPORT_DBG(lport, "Received FLOGI request while in state %s\n", |
814 | fc_lport_state(lport)); | 813 | fc_lport_state(lport)); |
815 | 814 | ||
816 | fh = fc_frame_header_get(rx_fp); | 815 | remote_fid = fc_frame_sid(rx_fp); |
817 | remote_fid = ntoh24(fh->fh_s_id); | ||
818 | flp = fc_frame_payload_get(rx_fp, sizeof(*flp)); | 816 | flp = fc_frame_payload_get(rx_fp, sizeof(*flp)); |
819 | if (!flp) | 817 | if (!flp) |
820 | goto out; | 818 | goto out; |
@@ -910,7 +908,7 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp, | |||
910 | recv = fc_lport_recv_flogi_req; | 908 | recv = fc_lport_recv_flogi_req; |
911 | break; | 909 | break; |
912 | case ELS_LOGO: | 910 | case ELS_LOGO: |
913 | if (ntoh24(fh->fh_s_id) == FC_FID_FLOGI) | 911 | if (fc_frame_sid(fp) == FC_FID_FLOGI) |
914 | recv = fc_lport_recv_logo_req; | 912 | recv = fc_lport_recv_logo_req; |
915 | break; | 913 | break; |
916 | case ELS_RSCN: | 914 | case ELS_RSCN: |
@@ -1468,7 +1466,6 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1468 | void *lp_arg) | 1466 | void *lp_arg) |
1469 | { | 1467 | { |
1470 | struct fc_lport *lport = lp_arg; | 1468 | struct fc_lport *lport = lp_arg; |
1471 | struct fc_frame_header *fh; | ||
1472 | struct fc_els_flogi *flp; | 1469 | struct fc_els_flogi *flp; |
1473 | u32 did; | 1470 | u32 did; |
1474 | u16 csp_flags; | 1471 | u16 csp_flags; |
@@ -1496,8 +1493,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1496 | goto err; | 1493 | goto err; |
1497 | } | 1494 | } |
1498 | 1495 | ||
1499 | fh = fc_frame_header_get(fp); | 1496 | did = fc_frame_did(fp); |
1500 | did = ntoh24(fh->fh_d_id); | ||
1501 | if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { | 1497 | if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { |
1502 | flp = fc_frame_payload_get(fp, sizeof(*flp)); | 1498 | flp = fc_frame_payload_get(fp, sizeof(*flp)); |
1503 | if (flp) { | 1499 | if (flp) { |
@@ -1523,7 +1519,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1523 | "Port (%6.6x) entered " | 1519 | "Port (%6.6x) entered " |
1524 | "point-to-point mode\n", | 1520 | "point-to-point mode\n", |
1525 | lport->host->host_no, did); | 1521 | lport->host->host_no, did); |
1526 | fc_lport_ptp_setup(lport, ntoh24(fh->fh_s_id), | 1522 | fc_lport_ptp_setup(lport, fc_frame_sid(fp), |
1527 | get_unaligned_be64( | 1523 | get_unaligned_be64( |
1528 | &flp->fl_wwpn), | 1524 | &flp->fl_wwpn), |
1529 | get_unaligned_be64( | 1525 | get_unaligned_be64( |
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index c06d63e4a00f..123493166824 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c | |||
@@ -747,13 +747,11 @@ static void fc_rport_recv_flogi_req(struct fc_lport *lport, | |||
747 | struct fc_rport_priv *rdata; | 747 | struct fc_rport_priv *rdata; |
748 | struct fc_frame *fp = rx_fp; | 748 | struct fc_frame *fp = rx_fp; |
749 | struct fc_exch *ep; | 749 | struct fc_exch *ep; |
750 | struct fc_frame_header *fh; | ||
751 | struct fc_seq_els_data rjt_data; | 750 | struct fc_seq_els_data rjt_data; |
752 | u32 sid, f_ctl; | 751 | u32 sid, f_ctl; |
753 | 752 | ||
754 | rjt_data.fp = NULL; | 753 | rjt_data.fp = NULL; |
755 | fh = fc_frame_header_get(fp); | 754 | sid = fc_frame_sid(fp); |
756 | sid = ntoh24(fh->fh_s_id); | ||
757 | 755 | ||
758 | FC_RPORT_ID_DBG(lport, sid, "Received FLOGI request\n"); | 756 | FC_RPORT_ID_DBG(lport, sid, "Received FLOGI request\n"); |
759 | 757 | ||
@@ -1430,17 +1428,14 @@ static void fc_rport_recv_els_req(struct fc_lport *lport, | |||
1430 | struct fc_seq *sp, struct fc_frame *fp) | 1428 | struct fc_seq *sp, struct fc_frame *fp) |
1431 | { | 1429 | { |
1432 | struct fc_rport_priv *rdata; | 1430 | struct fc_rport_priv *rdata; |
1433 | struct fc_frame_header *fh; | ||
1434 | struct fc_seq_els_data els_data; | 1431 | struct fc_seq_els_data els_data; |
1435 | 1432 | ||
1436 | els_data.fp = NULL; | 1433 | els_data.fp = NULL; |
1437 | els_data.reason = ELS_RJT_UNAB; | 1434 | els_data.reason = ELS_RJT_UNAB; |
1438 | els_data.explan = ELS_EXPL_PLOGI_REQD; | 1435 | els_data.explan = ELS_EXPL_PLOGI_REQD; |
1439 | 1436 | ||
1440 | fh = fc_frame_header_get(fp); | ||
1441 | |||
1442 | mutex_lock(&lport->disc.disc_mutex); | 1437 | mutex_lock(&lport->disc.disc_mutex); |
1443 | rdata = lport->tt.rport_lookup(lport, ntoh24(fh->fh_s_id)); | 1438 | rdata = lport->tt.rport_lookup(lport, fc_frame_sid(fp)); |
1444 | if (!rdata) { | 1439 | if (!rdata) { |
1445 | mutex_unlock(&lport->disc.disc_mutex); | 1440 | mutex_unlock(&lport->disc.disc_mutex); |
1446 | goto reject; | 1441 | goto reject; |
@@ -1555,14 +1550,12 @@ static void fc_rport_recv_plogi_req(struct fc_lport *lport, | |||
1555 | struct fc_rport_priv *rdata; | 1550 | struct fc_rport_priv *rdata; |
1556 | struct fc_frame *fp = rx_fp; | 1551 | struct fc_frame *fp = rx_fp; |
1557 | struct fc_exch *ep; | 1552 | struct fc_exch *ep; |
1558 | struct fc_frame_header *fh; | ||
1559 | struct fc_els_flogi *pl; | 1553 | struct fc_els_flogi *pl; |
1560 | struct fc_seq_els_data rjt_data; | 1554 | struct fc_seq_els_data rjt_data; |
1561 | u32 sid, f_ctl; | 1555 | u32 sid, f_ctl; |
1562 | 1556 | ||
1563 | rjt_data.fp = NULL; | 1557 | rjt_data.fp = NULL; |
1564 | fh = fc_frame_header_get(fp); | 1558 | sid = fc_frame_sid(fp); |
1565 | sid = ntoh24(fh->fh_s_id); | ||
1566 | 1559 | ||
1567 | FC_RPORT_ID_DBG(lport, sid, "Received PLOGI request\n"); | 1560 | FC_RPORT_ID_DBG(lport, sid, "Received PLOGI request\n"); |
1568 | 1561 | ||
@@ -1682,7 +1675,6 @@ static void fc_rport_recv_prli_req(struct fc_rport_priv *rdata, | |||
1682 | struct fc_lport *lport = rdata->local_port; | 1675 | struct fc_lport *lport = rdata->local_port; |
1683 | struct fc_exch *ep; | 1676 | struct fc_exch *ep; |
1684 | struct fc_frame *fp; | 1677 | struct fc_frame *fp; |
1685 | struct fc_frame_header *fh; | ||
1686 | struct { | 1678 | struct { |
1687 | struct fc_els_prli prli; | 1679 | struct fc_els_prli prli; |
1688 | struct fc_els_spp spp; | 1680 | struct fc_els_spp spp; |
@@ -1698,12 +1690,10 @@ static void fc_rport_recv_prli_req(struct fc_rport_priv *rdata, | |||
1698 | u32 roles = FC_RPORT_ROLE_UNKNOWN; | 1690 | u32 roles = FC_RPORT_ROLE_UNKNOWN; |
1699 | 1691 | ||
1700 | rjt_data.fp = NULL; | 1692 | rjt_data.fp = NULL; |
1701 | fh = fc_frame_header_get(rx_fp); | ||
1702 | |||
1703 | FC_RPORT_DBG(rdata, "Received PRLI request while in state %s\n", | 1693 | FC_RPORT_DBG(rdata, "Received PRLI request while in state %s\n", |
1704 | fc_rport_state(rdata)); | 1694 | fc_rport_state(rdata)); |
1705 | 1695 | ||
1706 | len = fr_len(rx_fp) - sizeof(*fh); | 1696 | len = fr_len(rx_fp) - sizeof(struct fc_frame_header); |
1707 | pp = fc_frame_payload_get(rx_fp, sizeof(*pp)); | 1697 | pp = fc_frame_payload_get(rx_fp, sizeof(*pp)); |
1708 | if (!pp) | 1698 | if (!pp) |
1709 | goto reject_len; | 1699 | goto reject_len; |
@@ -1817,7 +1807,6 @@ static void fc_rport_recv_prlo_req(struct fc_rport_priv *rdata, | |||
1817 | struct fc_frame *rx_fp) | 1807 | struct fc_frame *rx_fp) |
1818 | { | 1808 | { |
1819 | struct fc_lport *lport = rdata->local_port; | 1809 | struct fc_lport *lport = rdata->local_port; |
1820 | struct fc_frame_header *fh; | ||
1821 | struct fc_exch *ep; | 1810 | struct fc_exch *ep; |
1822 | struct fc_frame *fp; | 1811 | struct fc_frame *fp; |
1823 | struct { | 1812 | struct { |
@@ -1832,12 +1821,11 @@ static void fc_rport_recv_prlo_req(struct fc_rport_priv *rdata, | |||
1832 | struct fc_seq_els_data rjt_data; | 1821 | struct fc_seq_els_data rjt_data; |
1833 | 1822 | ||
1834 | rjt_data.fp = NULL; | 1823 | rjt_data.fp = NULL; |
1835 | fh = fc_frame_header_get(rx_fp); | ||
1836 | 1824 | ||
1837 | FC_RPORT_DBG(rdata, "Received PRLO request while in state %s\n", | 1825 | FC_RPORT_DBG(rdata, "Received PRLO request while in state %s\n", |
1838 | fc_rport_state(rdata)); | 1826 | fc_rport_state(rdata)); |
1839 | 1827 | ||
1840 | len = fr_len(rx_fp) - sizeof(*fh); | 1828 | len = fr_len(rx_fp) - sizeof(struct fc_frame_header); |
1841 | pp = fc_frame_payload_get(rx_fp, sizeof(*pp)); | 1829 | pp = fc_frame_payload_get(rx_fp, sizeof(*pp)); |
1842 | if (!pp) | 1830 | if (!pp) |
1843 | goto reject_len; | 1831 | goto reject_len; |
@@ -1901,14 +1889,12 @@ static void fc_rport_recv_logo_req(struct fc_lport *lport, | |||
1901 | struct fc_seq *sp, | 1889 | struct fc_seq *sp, |
1902 | struct fc_frame *fp) | 1890 | struct fc_frame *fp) |
1903 | { | 1891 | { |
1904 | struct fc_frame_header *fh; | ||
1905 | struct fc_rport_priv *rdata; | 1892 | struct fc_rport_priv *rdata; |
1906 | u32 sid; | 1893 | u32 sid; |
1907 | 1894 | ||
1908 | lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); | 1895 | lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); |
1909 | 1896 | ||
1910 | fh = fc_frame_header_get(fp); | 1897 | sid = fc_frame_sid(fp); |
1911 | sid = ntoh24(fh->fh_s_id); | ||
1912 | 1898 | ||
1913 | mutex_lock(&lport->disc.disc_mutex); | 1899 | mutex_lock(&lport->disc.disc_mutex); |
1914 | rdata = lport->tt.rport_lookup(lport, sid); | 1900 | rdata = lport->tt.rport_lookup(lport, sid); |