Fix the openfc Makefile to build as included in kernel
PATCH 1/6 Fix the openfc Makefile to build as included in kernel
The current build for openfc will fail as it only builds as module.
---
drivers/scsi/ofc/openfc/Makefile | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
drivers/scsi/ofc/openfc/Makefile +7 -4
@@ -9,7 +9,10 @@ openfc-y := \ openfc_if.o \ openfc_ioctl.o \ openfc_pkt.o \ - openfc_scsi.o \ - ../libfc/libfc.o \ - ../libsa/libsa.o \ - ../libcrc/libcrc.o + openfc_scsi.o + +ifeq ($(CONFIG_OFC),m) + openfc-y += ../libfc/libfc.o \ + ../libsa/libsa.o \ + ../libcrc/libcrc.o +endif
PATCH 2/6 hash for fc_remote_port: do not use sa_hash_xxx
1. Add hash table/funcs for fc_remote_port
2. Remove association with vf_rport_by_fid in fc_virt_fab
3. Remove association with vf_rport_by_wwpn in fc_virt_fab
4. Remove references to sa_hash_xxx
---
drivers/scsi/ofc/include/fc_remote_port.h | 5 drivers/scsi/ofc/libfc/fc_remote_port.c | 387 +++++++++++++++++++---------- 2 files changed, 254 insertions(+), 138 deletions(-)
drivers/scsi/ofc/include/fc_remote_port.h +2 -3
@@ -21,7 +21,6 @@#define _LIBFC_REMOTE_PORT_H_#include "sa_kernel.h" -#include "sa_hash.h" /* * Fibre Channel Remote Ports.
@@ -46,8 +45,8 @@ struct fc_remote_port {void *rp_client_priv;/* HBA driver private data */ void *rp_fcs_priv;/* FCS driver private data */ struct sa_event_list *rp_events;/* event list */ -struct sa_hash_link rp_fid_hash_link; -struct sa_hash_link rp_wwpn_hash_link; +struct hlist_node rp_fid_hash_link; +struct hlist_node rp_wwpn_hash_link;/* * For now, there's just one session per remote port.
drivers/scsi/ofc/libfc/fc_remote_port.c +252 -135
491 lines not on this page · raw message
PATCH 3/6 hash for fc_sess: do not use sa_hash_xxx
In reply to Yi Zou1. Add hash table/funcs for fc_sess
2. Remove association with vf_sess_by_fids in fc_virt_fab
4. Remove refrences to sa_hash_xxx
---
drivers/scsi/ofc/include/fc_sess.h | 2 drivers/scsi/ofc/libfc/fc_sess.c | 226 +++++++++++++++++++++++---------- drivers/scsi/ofc/libfc/fc_sess_impl.h | 2 3 files changed, 162 insertions(+), 68 deletions(-)
drivers/scsi/ofc/include/fc_sess.h +2 -0
@@ -81,6 +81,8 @@ static inline u_int64_t fc_sess_key(fc_fid_t local, fc_fid_t remote)int fc_sess_table_create (struct fc_virt_fab *);void fc_sess_table_destroy (struct fc_virt_fab *); +struct fc_sess *fc_sess_hash_lookup (const u_int64_t *key); +/* * Lookup or create a new session. */
drivers/scsi/ofc/libfc/fc_sess.c +159 -67
296 lines not on this page · raw message
drivers/scsi/ofc/libfc/fc_sess_impl.h +1 -1
@@ -61,7 +61,7 @@ struct fc_sess { uint8_t fs_plogi_held : 1; /* sess held by remote login */struct sa_event_list *fs_events;/* event list */ enum fc_event fs_last_event;/* last reported event to clients */ -struct sa_hash_link fs_hash_link;/* link in hash by port pair */ +struct hlist_node fs_hash_link;/* link in hash by port pair */ struct fc_lun_disc *fs_lun_disc;/* active LUN discovery if any */ spinlock_t fs_lock;/* lock on state changes */ struct rcu_head fs_rcu;/* element for call_rcu() */
PATCH 4/6 hash for fc_local_port: do not use sa_hash_xxx
In reply to Yi Zou1. Add hash table/funcs for fc_local_port
2. Remove association with vf_lport_by_fid in fc_virt_fab
3. Remove references to sa_hash_xxx
---
drivers/scsi/ofc/libfc/fc_local_port.c | 184 +++++++++++++++++---------- drivers/scsi/ofc/libfc/fc_local_port_impl.h | 3 2 files changed, 117 insertions(+), 70 deletions(-)
drivers/scsi/ofc/libfc/fc_local_port.c +116 -68
@@ -28,7 +28,6 @@#include "net_types.h" #include "ofc_dbg.h" #include "sa_event.h" -#include "sa_hash.h" #include "fc_fs.h" #include "fc_gs.h"
@@ -92,6 +91,109 @@ static void fc_local_port_port_event(int, void *);static void fc_local_port_set_fid_int (struct fc_local_port *,fc_fid_t );static void fc_local_port_gid_pn_error (enum fc_event ,void *arg); +/* +* Hash table size for local port +*/ +#define FC_HASH_LPORT_SHIFT 3 +#define FC_HASH_LPORT_BUCKETS (1UL << FC_HASH_LPORT_SHIFT) +#define FC_HASH_LPORT_MASK (FC_HASH_LPORT_BUCKETS - 1) + +static u_int32_t lport_hash_entries; +static struct hlist_head lport_hash_table[FC_HASH_LPORT_BUCKETS ]; + +/** +* fc_local_port_match - the compare function for hash lookup +* @fid: the ptr to fcid as the input +* @lp: the ptr to the local port to be matched +*/ +static inline int fc_local_port_match (const fc_fid_t *fid, +const struct fc_local_port *lp) +{ +return *fid == lp->fl_fid; +} + +/** +* fc_local_port_hash - a simple hash function of fcid +* @fid: the ptr to a given fcid +*/ +static inline u_int32_t fc_local_port_hash (const fc_fid_t *fid) +{ +return (((*fid) >>8 ) ^ (*fid)) &FC_HASH_LPORT_MASK ; +} + +/** +* fc_local_port_hash_lookup - lookup the hash table +* @fid: the ptr to a given fcid as key +* +* caller should acquire the lock appropriately, use RCU lock if +* no write, otherwise use spinlock such as vf_lock before calling. +*/ +static inline struct fc_local_port *fc_local_port_hash_lookup ( +const fc_fid_t *fid) +{ +struct hlist_node *node; +struct hlist_head *head; +struct fc_local_port *lp; + + head = &lport_hash_table[fc_local_port_hash (fid)]; +hlist_for_each_entry_rcu (lp, node, head, fl_hash_link) +if (fc_local_port_match (fid, lp)) +return lp; +return NULL ; +} + +/** +* fc_local_port_hash_delete - remove the local port from the hash table +* @lp: the ptr to the local port to be removed +* +* caller should acquire the lock before calling, e.g. vf_lock. +*/ +static inline void fc_local_port_hash_delete (const struct fc_local_port *lp) +{ +hlist_del_rcu ((struct hlist_node *)&lp->fl_hash_link); + lport_hash_entries--; +} + +/** +* fc_local_port_hash_insert - remove the local port from the hash table +* @lp: the ptr to the local port to be removed +* +* caller should acquire the lock before calling, e.g. vf_lock. +*/ +static inline void fc_local_port_hash_insert (const struct fc_local_port *lp) +{ +struct hlist_head *head; + + head = &lport_hash_table[fc_local_port_hash (&lp->fl_fid)]; +hlist_add_head_rcu ((struct hlist_node *)&lp->fl_hash_link, head); + lport_hash_entries++; +} + +/** +* fc_local_port_hash_init - initalize the hlist_head for each bucket +*/ +static void fc_local_port_hash_init (void ) +{ +int loop; +for (loop =0 ; loop <FC_HASH_LPORT_BUCKETS ; loop++) +INIT_HLIST_HEAD (&lport_hash_table[loop]); + lport_hash_entries =0 ; +} + +int fc_local_port_table_create (struct fc_virt_fab *vf) +{ +fc_local_port_hash_init (); +INIT_LIST_HEAD (&vf->vf_local_ports); +return 0 ; +} + +void fc_local_port_table_destroy (struct fc_virt_fab *vf) +{ +WARN_ON (!list_empty (&vf->vf_local_ports)); +fc_local_port_hash_init (); +INIT_LIST_HEAD (&vf->vf_local_ports); +} +static inline void fc_local_port_enter_state (struct fc_local_port *lp,enum fc_local_port_state state) {
@@ -225,20 +327,6 @@ static void fc_local_port_retry(struct fc_local_port *lp) }/* -* Declare hash table type for lookup by FCID. -*/ -#define FC_LOCAL_PORT_HASH_SIZE 8/* smallish for now */ - -static int fc_local_port_fid_match (sa_hash_key_t ,void *); -static u_int32_t fc_local_port_fid_hash (sa_hash_key_t ); - -static struct sa_hash_type fc_local_port_hash_by_fid = { - .st_link_offset = offsetof(struct fc_local_port , fl_hash_link), - .st_match = fc_local_port_fid_match, - .st_hash = fc_local_port_fid_hash, -}; - -/* * Return max segment size for local port. */ static u_int fc_local_port_mfs (struct fc_local_port *lp)
@@ -842,29 +930,6 @@ static void fc_local_port_enter_logo(struct fc_local_port *lp)fc_local_port_els_send (lp, sp, fp); } -int fc_local_port_table_create (struct fc_virt_fab *vp) -{ -struct sa_hash *hp; - -WARN_ON (vp->vf_lport_by_fid); - - hp =sa_hash_create (&fc_local_port_hash_by_fid, -FC_LOCAL_PORT_HASH_SIZE ); - -if (!hp) -return -1 ; - vp->vf_lport_by_fid = hp; -INIT_LIST_HEAD (&vp->vf_local_ports); - -return 0 ; -} - -void fc_local_port_table_destroy (struct fc_virt_fab *vp) -{ -WARN_ON (!list_empty (&vp->vf_local_ports)); -sa_hash_destroy (vp->vf_lport_by_fid); -} -/* * Create Local Port. */
@@ -928,26 +993,24 @@ err:static void fc_local_port_set_fid_int (struct fc_local_port *lp,fc_fid_t fid) {struct fc_local_port *found; -struct fc_virt_fab *vf; - vf = lp->fl_vf;if (lp->fl_fid != fid) {if (fc_local_port_debug) {OFC_DBG ("changing local port fid from %x to %x" , lp->fl_fid, fid); } -fc_virt_fab_lock (vf); +fc_virt_fab_lock (lp->fl_vf);if (lp->fl_fid) { - found =sa_hash_lookup_delete (vf->vf_lport_by_fid, - &lp->fl_fid); + found =fc_local_port_hash_lookup (&lp->fl_fid);WARN_ON (found != lp); +fc_local_port_hash_delete (found); } -WARN_ON (sa_hash_lookup (vf->vf_lport_by_fid, &fid)); +WARN_ON (fc_local_port_hash_lookup (&lp->fl_fid)); lp->fl_fid = fid; -if (fid !=0 ) -sa_hash_insert (vf->vf_lport_by_fid, &fid, lp); -fc_virt_fab_unlock (vf); -fc_sess_reset_list (vf, &lp->fl_sess_list); +if (lp->fl_fid !=0 ) +fc_local_port_hash_insert (lp); +fc_virt_fab_unlock (lp->fl_vf); +fc_sess_reset_list (lp->fl_vf, &lp->fl_sess_list); } }
@@ -1016,20 +1079,19 @@ struct fc_els_rnid_gen *fc_local_port_get_rnidp(struct fc_local_port *lp)static void fc_local_port_delete (struct fc_local_port *lp) {struct fc_local_port *found; -struct fc_virt_fab *vf;if (fc_local_port_debug)OFC_DBG ("local port %6x delete" , lp->fl_fid); - vf = lp->fl_vf; -fc_virt_fab_lock (vf); +fc_virt_fab_lock (lp->fl_vf);if (lp->fl_fid) { - found =sa_hash_lookup_delete (vf->vf_lport_by_fid, &lp->fl_fid); + found =fc_local_port_hash_lookup (&lp->fl_fid);WARN_ON (found != lp); +fc_local_port_hash_delete (found); lp->fl_fid =0 ; }list_del (&lp->fl_list); -fc_virt_fab_unlock (vf); +fc_virt_fab_unlock (lp->fl_vf);sa_event_list_free (lp->fl_events);sa_free (lp); }
@@ -1551,7 +1613,7 @@ void fc_local_port_recv(struct fc_local_port *lp, struct fc_frame *fp) d_id =net24_get (&fh->fh_d_id); key =fc_sess_key (d_id, s_id);rcu_read_lock (); - sess =sa_hash_lookup (lp->fl_vf->vf_sess_by_fids, &key); + sess =fc_sess_hash_lookup (&key);if (!sess) {rcu_read_unlock (); fc_exch_recv_req(mp, fp, lp->fl_max_payload,
@@ -1603,20 +1665,6 @@ static void fc_local_port_error(enum fc_event event, void *lp_arg)fc_local_port_unlock_send (lp); } -static int fc_local_port_fid_match (const sa_hash_key_t key,void *lp_arg) -{ -struct fc_local_port *lp = lp_arg; - -return *(fc_fid_t *) key == lp->fl_fid; -} - -static u_int32_t fc_local_port_fid_hash (const sa_hash_key_t key) -{ -fc_fid_t fid = *(fc_fid_t *) key; - -return (fid >>8 ) ^ fid; -} -/* * Handle state change from the ingress/egress port. */
drivers/scsi/ofc/libfc/fc_local_port_impl.h +1 -2
@@ -23,7 +23,6 @@#include <linux/timer.h> #include "fc_sess.h" #include "fc_sess_impl.h" -#include "sa_hash.h" #include "fc_ns.h" struct fc_els_rscn_page ;
@@ -82,7 +81,7 @@ struct fc_local_port { void *); /* callback for incoming PRLI */void *fl_prli_cb_arg;/* arg for PRLI callback */ struct sa_event_list *fl_events;/* event list head */ -struct sa_hash_link fl_hash_link;/* hash list linkage */ +struct hlist_node fl_hash_link;/* hash list linkage */ struct timer_list fl_timer;/* timer for state events */ /*
PATCH 5/6 remove hash tables from fc_virt_fab
In reply to Yi ZouRemove vf_rport_by_fid, vf_rport_by_wwn, vf_lport_by_fid, vf_sess_by_fids in struct fc_virt_fab of fc_virt_fab_impl.h
---
drivers/scsi/ofc/libfc/fc_virt_fab_impl.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/scsi/ofc/libfc/fc_virt_fab_impl.h +0 -4
@@ -23,10 +23,6 @@struct fc_virt_fab {uint vf_tag;/* virtual fabric tag (or zero) */ struct list_head vf_remote_ports;/* remote ports */ -struct sa_hash *vf_rport_by_fid;/* remote ports by FCID */ -struct sa_hash *vf_rport_by_wwpn;/* remote ports by WWPN */ -struct sa_hash *vf_lport_by_fid;/* local ports by FCID */ -struct sa_hash *vf_sess_by_fids;/* sessions by FCID pairs */ struct list_head vf_local_ports;/* list of local ports */ struct fc_exch_mgr *vf_exch_mgr;/* exchange mgr for fabric */ spinlock_t vf_lock;/* lock for all tables and lists */
PATCH 6/6 remove sa_hash_kern.c/sa_hash.h
In reply to Yi Zou1. Remove libsa/sa_hash_kern.c
2. Remove include/sa_hash.h
3. Remove all references to sa_hash_xxx
4. Update Makefile accordingly in libsa
---
drivers/scsi/ofc/include/sa_hash.h | 65 --------------- drivers/scsi/ofc/libfc/fc_exch.c | 1 drivers/scsi/ofc/libfc/fc_sess_impl.h | 1 drivers/scsi/ofc/libsa/Makefile | 4 - drivers/scsi/ofc/libsa/sa_hash_kern.c | 141 --------------------------------- 5 files changed, 1 insertions(+), 211 deletions(-) delete mode 100644 drivers/scsi/ofc/include/sa_hash.h delete mode 100644 drivers/scsi/ofc/libsa/sa_hash_kern.c
drivers/scsi/ofc/include/sa_hash.h deleted +0 -65
@@ -1,65 +0,0 @@ -/* -* Copyright(c) 2007 Intel Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. -* -* Maintained at www.Open-FCoE.org -*/ - -#ifndef _LIBSA_HASH_H_ -#define _LIBSA_HASH_H_ - -#include <linux/list.h> - -/* -* Hash table facility. -*/ -struct sa_hash ; - -/* -* Hash key value. -*/ -typedef void *sa_hash_key_t ;/* pointer hash key */ -typedef u_int32_t sa_hash_key32_t ;/* fixed-size 32-bit hash key */ - -struct sa_hash_type { -u_int16_t st_link_offset;/* offset of linkage in the element */ -int (*st_match)(const sa_hash_key_t ,void *elem); -u_int32_t (*st_hash)(const sa_hash_key_t ); -}; - -/* -* Element linkage on the hash. -* The collision list is circular. -*/ -#define sa_hash_link hlist_node - -struct sa_hash *sa_hash_create (const struct sa_hash_type *,u_int32_t size); - -void sa_hash_destroy (struct sa_hash *); - -void *sa_hash_lookup (struct sa_hash *,const sa_hash_key_t ); - -void sa_hash_insert (struct sa_hash *,const sa_hash_key_t ,void *elem); - -void sa_hash_insert_next (struct sa_hash *,sa_hash_key32_t *, -sa_hash_key32_t min_key,sa_hash_key32_t max_key, -void *elem); - -void *sa_hash_lookup_delete (struct sa_hash *,const sa_hash_key_t ); - -void sa_hash_iterate (struct sa_hash *, -void (*callback)(void *entry,void *arg),void *arg); - -#endif /* _LIBSA_HASH_H_ */
drivers/scsi/ofc/libfc/fc_exch.c +0 -1
@@ -27,7 +27,6 @@#include "sa_kernel.h" #include "net_types.h" #include "ofc_dbg.h" -#include "sa_hash.h" #include "fc_fcip.h" #include "fc_fc2.h"
drivers/scsi/ofc/libfc/fc_sess_impl.h +0 -1
@@ -22,7 +22,6 @@#include <linux/timer.h> #include "fc_exch.h" -#include "sa_hash.h" #include <linux/rcupdate.h>
drivers/scsi/ofc/libsa/Makefile +1 -3
@@ -4,6 +4,4 @@ EXTRA_CFLAGS += -I$(OFC_DIR)/include obj-y += libsa.o -libsa-y := \ - sa_event.o \ - sa_hash_kern.o +libsa-y := sa_event.o
drivers/scsi/ofc/libsa/sa_hash_kern.c deleted +0 -141
141 lines not on this page · raw message