sched: use group_first_cpu() instead of cpumask_first(sched_group_cpus())
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / scsi / libfcoe.h
blob666cc131732ee3cfc7715a6568dabcd57a1e42e2
1 /*
2 * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007-2008 Intel Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 * Maintained at www.Open-FCoE.org
21 #ifndef _LIBFCOE_H
22 #define _LIBFCOE_H
24 #include <linux/etherdevice.h>
25 #include <linux/if_ether.h>
26 #include <linux/netdevice.h>
27 #include <linux/skbuff.h>
28 #include <linux/workqueue.h>
29 #include <scsi/fc/fc_fcoe.h>
30 #include <scsi/libfc.h>
33 * FIP tunable parameters.
35 #define FCOE_CTLR_START_DELAY 2000 /* mS after first adv. to choose FCF */
36 #define FCOE_CTRL_SOL_TOV 2000 /* min. solicitation interval (mS) */
37 #define FCOE_CTLR_FCF_LIMIT 20 /* max. number of FCF entries */
39 /**
40 * enum fip_state - internal state of FCoE controller.
41 * @FIP_ST_DISABLED: controller has been disabled or not yet enabled.
42 * @FIP_ST_LINK_WAIT: the physical link is down or unusable.
43 * @FIP_ST_AUTO: determining whether to use FIP or non-FIP mode.
44 * @FIP_ST_NON_FIP: non-FIP mode selected.
45 * @FIP_ST_ENABLED: FIP mode selected.
47 enum fip_state {
48 FIP_ST_DISABLED,
49 FIP_ST_LINK_WAIT,
50 FIP_ST_AUTO,
51 FIP_ST_NON_FIP,
52 FIP_ST_ENABLED,
55 /**
56 * struct fcoe_ctlr - FCoE Controller and FIP state.
57 * @state: internal FIP state for network link and FIP or non-FIP mode.
58 * @lp: &fc_lport: libfc local port.
59 * @sel_fcf: currently selected FCF, or NULL.
60 * @fcfs: list of discovered FCFs.
61 * @fcf_count: number of discovered FCF entries.
62 * @sol_time: time when a multicast solicitation was last sent.
63 * @sel_time: time after which to select an FCF.
64 * @port_ka_time: time of next port keep-alive.
65 * @ctlr_ka_time: time of next controller keep-alive.
66 * @timer: timer struct used for all delayed events.
67 * @link_work: &work_struct for doing FCF selection.
68 * @recv_work: &work_struct for receiving FIP frames.
69 * @fip_recv_list: list of received FIP frames.
70 * @user_mfs: configured maximum FC frame size, including FC header.
71 * @flogi_oxid: exchange ID of most recent fabric login.
72 * @flogi_count: number of FLOGI attempts in AUTO mode.
73 * @link: current link status for libfc.
74 * @last_link: last link state reported to libfc.
75 * @map_dest: use the FC_MAP mode for destination MAC addresses.
76 * @dest_addr: MAC address of the selected FC forwarder.
77 * @ctl_src_addr: the native MAC address of our local port.
78 * @data_src_addr: the assigned MAC address for the local port after FLOGI.
79 * @send: LLD-supplied function to handle sending of FIP Ethernet frames.
80 * @update_mac: LLD-supplied function to handle changes to MAC addresses.
81 * @lock: lock protecting this structure.
83 * This structure is used by all FCoE drivers. It contains information
84 * needed by all FCoE low-level drivers (LLDs) as well as internal state
85 * for FIP, and fields shared with the LLDS.
87 struct fcoe_ctlr {
88 enum fip_state state;
89 struct fc_lport *lp;
90 struct fcoe_fcf *sel_fcf;
91 struct list_head fcfs;
92 u16 fcf_count;
93 unsigned long sol_time;
94 unsigned long sel_time;
95 unsigned long port_ka_time;
96 unsigned long ctlr_ka_time;
97 struct timer_list timer;
98 struct work_struct link_work;
99 struct work_struct recv_work;
100 struct sk_buff_head fip_recv_list;
101 u16 user_mfs;
102 u16 flogi_oxid;
103 u8 flogi_count;
104 u8 link;
105 u8 last_link;
106 u8 map_dest;
107 u8 dest_addr[ETH_ALEN];
108 u8 ctl_src_addr[ETH_ALEN];
109 u8 data_src_addr[ETH_ALEN];
111 void (*send)(struct fcoe_ctlr *, struct sk_buff *);
112 void (*update_mac)(struct fcoe_ctlr *, u8 *old, u8 *new);
113 spinlock_t lock;
117 * struct fcoe_fcf - Fibre-Channel Forwarder.
118 * @list: list linkage.
119 * @time: system time (jiffies) when an advertisement was last received.
120 * @switch_name: WWN of switch from advertisement.
121 * @fabric_name: WWN of fabric from advertisement.
122 * @fc_map: FC_MAP value from advertisement.
123 * @fcf_mac: Ethernet address of the FCF.
124 * @vfid: virtual fabric ID.
125 * @pri: seletion priority, smaller values are better.
126 * @flags: flags received from advertisement.
127 * @fka_period: keep-alive period, in jiffies.
129 * A Fibre-Channel Forwarder (FCF) is the entity on the Ethernet that
130 * passes FCoE frames on to an FC fabric. This structure represents
131 * one FCF from which advertisements have been received.
133 * When looking up an FCF, @switch_name, @fabric_name, @fc_map, @vfid, and
134 * @fcf_mac together form the lookup key.
136 struct fcoe_fcf {
137 struct list_head list;
138 unsigned long time;
140 u64 switch_name;
141 u64 fabric_name;
142 u32 fc_map;
143 u16 vfid;
144 u8 fcf_mac[ETH_ALEN];
146 u8 pri;
147 u16 flags;
148 u32 fka_period;
151 /* FIP API functions */
152 void fcoe_ctlr_init(struct fcoe_ctlr *);
153 void fcoe_ctlr_destroy(struct fcoe_ctlr *);
154 void fcoe_ctlr_link_up(struct fcoe_ctlr *);
155 int fcoe_ctlr_link_down(struct fcoe_ctlr *);
156 int fcoe_ctlr_els_send(struct fcoe_ctlr *, struct sk_buff *);
157 void fcoe_ctlr_recv(struct fcoe_ctlr *, struct sk_buff *);
158 int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_frame *fp, u8 *sa);
160 /* libfcoe funcs */
161 u64 fcoe_wwn_from_mac(unsigned char mac[], unsigned int, unsigned int);
162 int fcoe_libfc_config(struct fc_lport *, struct libfc_function_template *);
164 #endif /* _LIBFCOE_H */