Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1 | /* |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 2 | * Copyright(c) 2007 - 2009 Intel Corporation. All rights reserved. |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along with |
| 14 | * this program; if not, write to the Free Software Foundation, Inc., |
| 15 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 16 | * |
| 17 | * Maintained at www.Open-FCoE.org |
| 18 | */ |
| 19 | |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/version.h> |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 22 | #include <linux/spinlock.h> |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 23 | #include <linux/netdevice.h> |
| 24 | #include <linux/etherdevice.h> |
| 25 | #include <linux/ethtool.h> |
| 26 | #include <linux/if_ether.h> |
| 27 | #include <linux/if_vlan.h> |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 28 | #include <linux/crc32.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 29 | #include <linux/slab.h> |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 30 | #include <linux/cpu.h> |
| 31 | #include <linux/fs.h> |
| 32 | #include <linux/sysfs.h> |
| 33 | #include <linux/ctype.h> |
Tejun Heo | 2ca32b4 | 2011-01-28 16:05:32 -0800 | [diff] [blame] | 34 | #include <linux/workqueue.h> |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 35 | #include <scsi/scsi_tcq.h> |
| 36 | #include <scsi/scsicam.h> |
| 37 | #include <scsi/scsi_transport.h> |
| 38 | #include <scsi/scsi_transport_fc.h> |
| 39 | #include <net/rtnetlink.h> |
| 40 | |
| 41 | #include <scsi/fc/fc_encaps.h> |
Joe Eykholt | 97c8389 | 2009-03-17 11:42:40 -0700 | [diff] [blame] | 42 | #include <scsi/fc/fc_fip.h> |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 43 | |
| 44 | #include <scsi/libfc.h> |
| 45 | #include <scsi/fc_frame.h> |
| 46 | #include <scsi/libfcoe.h> |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 47 | |
Vasu Dev | fdd78027 | 2009-03-17 11:42:24 -0700 | [diff] [blame] | 48 | #include "fcoe.h" |
| 49 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 50 | MODULE_AUTHOR("Open-FCoE.org"); |
| 51 | MODULE_DESCRIPTION("FCoE"); |
Vasu Dev | 9b34ecf | 2009-03-17 11:42:13 -0700 | [diff] [blame] | 52 | MODULE_LICENSE("GPL v2"); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 53 | |
Yi Zou | 05cc739 | 2009-08-25 13:59:03 -0700 | [diff] [blame] | 54 | /* Performance tuning parameters for fcoe */ |
| 55 | static unsigned int fcoe_ddp_min; |
| 56 | module_param_named(ddp_min, fcoe_ddp_min, uint, S_IRUGO | S_IWUSR); |
| 57 | MODULE_PARM_DESC(ddp_min, "Minimum I/O size in bytes for " \ |
| 58 | "Direct Data Placement (DDP)."); |
| 59 | |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 60 | DEFINE_MUTEX(fcoe_config_mutex); |
| 61 | |
Tejun Heo | 2ca32b4 | 2011-01-28 16:05:32 -0800 | [diff] [blame] | 62 | static struct workqueue_struct *fcoe_wq; |
| 63 | |
Joe Eykholt | e7a5199 | 2009-08-25 14:04:08 -0700 | [diff] [blame] | 64 | /* fcoe_percpu_clean completion. Waiter protected by fcoe_create_mutex */ |
| 65 | static DECLARE_COMPLETION(fcoe_flush_completion); |
| 66 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 67 | /* fcoe host list */ |
Chris Leech | 090eb6c | 2009-08-25 14:00:28 -0700 | [diff] [blame] | 68 | /* must only by accessed under the RTNL mutex */ |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 69 | LIST_HEAD(fcoe_hostlist); |
Robert Love | 5e5e92d | 2009-03-17 11:41:35 -0700 | [diff] [blame] | 70 | DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 71 | |
Chris Leech | dd3fd72 | 2009-04-21 16:27:36 -0700 | [diff] [blame] | 72 | /* Function Prototypes */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 73 | static int fcoe_reset(struct Scsi_Host *); |
Vasu Dev | fdd78027 | 2009-03-17 11:42:24 -0700 | [diff] [blame] | 74 | static int fcoe_xmit(struct fc_lport *, struct fc_frame *); |
| 75 | static int fcoe_rcv(struct sk_buff *, struct net_device *, |
| 76 | struct packet_type *, struct net_device *); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 77 | static int fcoe_percpu_receive_thread(void *); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 78 | static void fcoe_percpu_clean(struct fc_lport *); |
Robert Love | 5e4f8fe | 2010-05-07 15:18:35 -0700 | [diff] [blame] | 79 | static int fcoe_link_speed_update(struct fc_lport *); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 80 | static int fcoe_link_ok(struct fc_lport *); |
Vasu Dev | fdd78027 | 2009-03-17 11:42:24 -0700 | [diff] [blame] | 81 | |
| 82 | static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *); |
| 83 | static int fcoe_hostlist_add(const struct fc_lport *); |
Vasu Dev | fdd78027 | 2009-03-17 11:42:24 -0700 | [diff] [blame] | 84 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 85 | static int fcoe_device_notification(struct notifier_block *, ulong, void *); |
| 86 | static void fcoe_dev_setup(void); |
| 87 | static void fcoe_dev_cleanup(void); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 88 | static struct fcoe_interface |
| 89 | *fcoe_hostlist_lookup_port(const struct net_device *); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 90 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 91 | static int fcoe_fip_recv(struct sk_buff *, struct net_device *, |
| 92 | struct packet_type *, struct net_device *); |
| 93 | |
| 94 | static void fcoe_fip_send(struct fcoe_ctlr *, struct sk_buff *); |
| 95 | static void fcoe_update_src_mac(struct fc_lport *, u8 *); |
| 96 | static u8 *fcoe_get_src_mac(struct fc_lport *); |
| 97 | static void fcoe_destroy_work(struct work_struct *); |
| 98 | |
| 99 | static int fcoe_ddp_setup(struct fc_lport *, u16, struct scatterlist *, |
| 100 | unsigned int); |
| 101 | static int fcoe_ddp_done(struct fc_lport *, u16); |
| 102 | |
| 103 | static int fcoe_cpu_callback(struct notifier_block *, unsigned long, void *); |
| 104 | |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 105 | static bool fcoe_match(struct net_device *netdev); |
| 106 | static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode); |
| 107 | static int fcoe_destroy(struct net_device *netdev); |
| 108 | static int fcoe_enable(struct net_device *netdev); |
| 109 | static int fcoe_disable(struct net_device *netdev); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 110 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 111 | static struct fc_seq *fcoe_elsct_send(struct fc_lport *, |
| 112 | u32 did, struct fc_frame *, |
| 113 | unsigned int op, |
| 114 | void (*resp)(struct fc_seq *, |
| 115 | struct fc_frame *, |
| 116 | void *), |
| 117 | void *, u32 timeout); |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 118 | static void fcoe_recv_frame(struct sk_buff *skb); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 119 | |
Yi Zou | b84056b | 2009-11-20 14:55:19 -0800 | [diff] [blame] | 120 | static void fcoe_get_lesb(struct fc_lport *, struct fc_els_lesb *); |
| 121 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 122 | /* notification function for packets from net device */ |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 123 | static struct notifier_block fcoe_notifier = { |
| 124 | .notifier_call = fcoe_device_notification, |
| 125 | }; |
| 126 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 127 | /* notification function for CPU hotplug events */ |
| 128 | static struct notifier_block fcoe_cpu_notifier = { |
| 129 | .notifier_call = fcoe_cpu_callback, |
| 130 | }; |
| 131 | |
Yi Zou | 8ca86f8 | 2011-01-28 16:05:11 -0800 | [diff] [blame] | 132 | static struct scsi_transport_template *fcoe_nport_scsi_transport; |
| 133 | static struct scsi_transport_template *fcoe_vport_scsi_transport; |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 134 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 135 | static int fcoe_vport_destroy(struct fc_vport *); |
| 136 | static int fcoe_vport_create(struct fc_vport *, bool disabled); |
| 137 | static int fcoe_vport_disable(struct fc_vport *, bool disable); |
| 138 | static void fcoe_set_vport_symbolic_name(struct fc_vport *); |
Joe Eykholt | 7d65b0d | 2010-03-12 16:08:02 -0800 | [diff] [blame] | 139 | static void fcoe_set_port_id(struct fc_lport *, u32, struct fc_frame *); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 140 | |
| 141 | static struct libfc_function_template fcoe_libfc_fcn_templ = { |
| 142 | .frame_send = fcoe_xmit, |
| 143 | .ddp_setup = fcoe_ddp_setup, |
| 144 | .ddp_done = fcoe_ddp_done, |
| 145 | .elsct_send = fcoe_elsct_send, |
Yi Zou | b84056b | 2009-11-20 14:55:19 -0800 | [diff] [blame] | 146 | .get_lesb = fcoe_get_lesb, |
Joe Eykholt | 7d65b0d | 2010-03-12 16:08:02 -0800 | [diff] [blame] | 147 | .lport_set_port_id = fcoe_set_port_id, |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 148 | }; |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 149 | |
Yi Zou | 8ca86f8 | 2011-01-28 16:05:11 -0800 | [diff] [blame] | 150 | struct fc_function_template fcoe_nport_fc_functions = { |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 151 | .show_host_node_name = 1, |
| 152 | .show_host_port_name = 1, |
| 153 | .show_host_supported_classes = 1, |
| 154 | .show_host_supported_fc4s = 1, |
| 155 | .show_host_active_fc4s = 1, |
| 156 | .show_host_maxframe_size = 1, |
| 157 | |
| 158 | .show_host_port_id = 1, |
| 159 | .show_host_supported_speeds = 1, |
| 160 | .get_host_speed = fc_get_host_speed, |
| 161 | .show_host_speed = 1, |
| 162 | .show_host_port_type = 1, |
| 163 | .get_host_port_state = fc_get_host_port_state, |
| 164 | .show_host_port_state = 1, |
| 165 | .show_host_symbolic_name = 1, |
| 166 | |
| 167 | .dd_fcrport_size = sizeof(struct fc_rport_libfc_priv), |
| 168 | .show_rport_maxframe_size = 1, |
| 169 | .show_rport_supported_classes = 1, |
| 170 | |
| 171 | .show_host_fabric_name = 1, |
| 172 | .show_starget_node_name = 1, |
| 173 | .show_starget_port_name = 1, |
| 174 | .show_starget_port_id = 1, |
| 175 | .set_rport_dev_loss_tmo = fc_set_rport_loss_tmo, |
| 176 | .show_rport_dev_loss_tmo = 1, |
| 177 | .get_fc_host_stats = fc_get_host_stats, |
| 178 | .issue_fc_host_lip = fcoe_reset, |
| 179 | |
| 180 | .terminate_rport_io = fc_rport_terminate_io, |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 181 | |
| 182 | .vport_create = fcoe_vport_create, |
| 183 | .vport_delete = fcoe_vport_destroy, |
| 184 | .vport_disable = fcoe_vport_disable, |
Chris Leech | dc8596d | 2009-11-03 11:47:18 -0800 | [diff] [blame] | 185 | .set_vport_symbolic_name = fcoe_set_vport_symbolic_name, |
Steve Ma | a51ab39 | 2009-11-03 11:47:34 -0800 | [diff] [blame] | 186 | |
| 187 | .bsg_request = fc_lport_bsg_request, |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 188 | }; |
| 189 | |
Yi Zou | 8ca86f8 | 2011-01-28 16:05:11 -0800 | [diff] [blame] | 190 | struct fc_function_template fcoe_vport_fc_functions = { |
Chris Leech | e9084bb | 2009-11-03 11:46:34 -0800 | [diff] [blame] | 191 | .show_host_node_name = 1, |
| 192 | .show_host_port_name = 1, |
| 193 | .show_host_supported_classes = 1, |
| 194 | .show_host_supported_fc4s = 1, |
| 195 | .show_host_active_fc4s = 1, |
| 196 | .show_host_maxframe_size = 1, |
| 197 | |
| 198 | .show_host_port_id = 1, |
| 199 | .show_host_supported_speeds = 1, |
| 200 | .get_host_speed = fc_get_host_speed, |
| 201 | .show_host_speed = 1, |
| 202 | .show_host_port_type = 1, |
| 203 | .get_host_port_state = fc_get_host_port_state, |
| 204 | .show_host_port_state = 1, |
| 205 | .show_host_symbolic_name = 1, |
| 206 | |
| 207 | .dd_fcrport_size = sizeof(struct fc_rport_libfc_priv), |
| 208 | .show_rport_maxframe_size = 1, |
| 209 | .show_rport_supported_classes = 1, |
| 210 | |
| 211 | .show_host_fabric_name = 1, |
| 212 | .show_starget_node_name = 1, |
| 213 | .show_starget_port_name = 1, |
| 214 | .show_starget_port_id = 1, |
| 215 | .set_rport_dev_loss_tmo = fc_set_rport_loss_tmo, |
| 216 | .show_rport_dev_loss_tmo = 1, |
| 217 | .get_fc_host_stats = fc_get_host_stats, |
| 218 | .issue_fc_host_lip = fcoe_reset, |
| 219 | |
| 220 | .terminate_rport_io = fc_rport_terminate_io, |
Steve Ma | a51ab39 | 2009-11-03 11:47:34 -0800 | [diff] [blame] | 221 | |
| 222 | .bsg_request = fc_lport_bsg_request, |
Chris Leech | e9084bb | 2009-11-03 11:46:34 -0800 | [diff] [blame] | 223 | }; |
| 224 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 225 | static struct scsi_host_template fcoe_shost_template = { |
| 226 | .module = THIS_MODULE, |
| 227 | .name = "FCoE Driver", |
| 228 | .proc_name = FCOE_NAME, |
| 229 | .queuecommand = fc_queuecommand, |
| 230 | .eh_abort_handler = fc_eh_abort, |
| 231 | .eh_device_reset_handler = fc_eh_device_reset, |
| 232 | .eh_host_reset_handler = fc_eh_host_reset, |
| 233 | .slave_alloc = fc_slave_alloc, |
| 234 | .change_queue_depth = fc_change_queue_depth, |
| 235 | .change_queue_type = fc_change_queue_type, |
| 236 | .this_id = -1, |
Vasu Dev | 14caf44 | 2009-10-15 17:46:55 -0700 | [diff] [blame] | 237 | .cmd_per_lun = 3, |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 238 | .can_queue = FCOE_MAX_OUTSTANDING_COMMANDS, |
| 239 | .use_clustering = ENABLE_CLUSTERING, |
| 240 | .sg_tablesize = SG_ALL, |
| 241 | .max_sectors = 0xffff, |
| 242 | }; |
| 243 | |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 244 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 245 | * fcoe_interface_setup() - Setup a FCoE interface |
| 246 | * @fcoe: The new FCoE interface |
| 247 | * @netdev: The net device that the fcoe interface is on |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 248 | * |
| 249 | * Returns : 0 for success |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 250 | * Locking: must be called with the RTNL mutex held |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 251 | */ |
| 252 | static int fcoe_interface_setup(struct fcoe_interface *fcoe, |
| 253 | struct net_device *netdev) |
| 254 | { |
| 255 | struct fcoe_ctlr *fip = &fcoe->ctlr; |
| 256 | struct netdev_hw_addr *ha; |
Yi Zou | 5bab87e | 2009-11-03 11:49:43 -0800 | [diff] [blame] | 257 | struct net_device *real_dev; |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 258 | u8 flogi_maddr[ETH_ALEN]; |
Yi Zou | b7a727f | 2009-10-21 16:28:03 -0700 | [diff] [blame] | 259 | const struct net_device_ops *ops; |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 260 | |
| 261 | fcoe->netdev = netdev; |
| 262 | |
Yi Zou | b7a727f | 2009-10-21 16:28:03 -0700 | [diff] [blame] | 263 | /* Let LLD initialize for FCoE */ |
| 264 | ops = netdev->netdev_ops; |
| 265 | if (ops->ndo_fcoe_enable) { |
| 266 | if (ops->ndo_fcoe_enable(netdev)) |
| 267 | FCOE_NETDEV_DBG(netdev, "Failed to enable FCoE" |
| 268 | " specific feature for LLD.\n"); |
| 269 | } |
| 270 | |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 271 | /* Do not support for bonding device */ |
| 272 | if ((netdev->priv_flags & IFF_MASTER_ALB) || |
| 273 | (netdev->priv_flags & IFF_SLAVE_INACTIVE) || |
| 274 | (netdev->priv_flags & IFF_MASTER_8023AD)) { |
john fastabend | 59d9251 | 2009-11-03 11:48:44 -0800 | [diff] [blame] | 275 | FCOE_NETDEV_DBG(netdev, "Bonded interfaces not supported\n"); |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 276 | return -EOPNOTSUPP; |
| 277 | } |
| 278 | |
| 279 | /* look for SAN MAC address, if multiple SAN MACs exist, only |
| 280 | * use the first one for SPMA */ |
Yi Zou | 5bab87e | 2009-11-03 11:49:43 -0800 | [diff] [blame] | 281 | real_dev = (netdev->priv_flags & IFF_802_1Q_VLAN) ? |
| 282 | vlan_dev_real_dev(netdev) : netdev; |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 283 | rcu_read_lock(); |
Yi Zou | 5bab87e | 2009-11-03 11:49:43 -0800 | [diff] [blame] | 284 | for_each_dev_addr(real_dev, ha) { |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 285 | if ((ha->type == NETDEV_HW_ADDR_T_SAN) && |
Yi Zou | bf36170 | 2009-11-03 11:49:38 -0800 | [diff] [blame] | 286 | (is_valid_ether_addr(ha->addr))) { |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 287 | memcpy(fip->ctl_src_addr, ha->addr, ETH_ALEN); |
| 288 | fip->spma = 1; |
| 289 | break; |
| 290 | } |
| 291 | } |
| 292 | rcu_read_unlock(); |
| 293 | |
| 294 | /* setup Source Mac Address */ |
| 295 | if (!fip->spma) |
| 296 | memcpy(fip->ctl_src_addr, netdev->dev_addr, netdev->addr_len); |
| 297 | |
| 298 | /* |
| 299 | * Add FCoE MAC address as second unicast MAC address |
| 300 | * or enter promiscuous mode if not capable of listening |
| 301 | * for multiple unicast MACs. |
| 302 | */ |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 303 | memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); |
Jiri Pirko | a748ee2 | 2010-04-01 21:22:09 +0000 | [diff] [blame] | 304 | dev_uc_add(netdev, flogi_maddr); |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 305 | if (fip->spma) |
Jiri Pirko | a748ee2 | 2010-04-01 21:22:09 +0000 | [diff] [blame] | 306 | dev_uc_add(netdev, fip->ctl_src_addr); |
Joe Eykholt | e10f8c6 | 2010-07-20 15:20:30 -0700 | [diff] [blame] | 307 | if (fip->mode == FIP_MODE_VN2VN) { |
| 308 | dev_mc_add(netdev, FIP_ALL_VN2VN_MACS); |
| 309 | dev_mc_add(netdev, FIP_ALL_P2P_MACS); |
| 310 | } else |
| 311 | dev_mc_add(netdev, FIP_ALL_ENODE_MACS); |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 312 | |
| 313 | /* |
| 314 | * setup the receive function from ethernet driver |
| 315 | * on the ethertype for the given device |
| 316 | */ |
| 317 | fcoe->fcoe_packet_type.func = fcoe_rcv; |
| 318 | fcoe->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE); |
| 319 | fcoe->fcoe_packet_type.dev = netdev; |
| 320 | dev_add_pack(&fcoe->fcoe_packet_type); |
| 321 | |
| 322 | fcoe->fip_packet_type.func = fcoe_fip_recv; |
| 323 | fcoe->fip_packet_type.type = htons(ETH_P_FIP); |
| 324 | fcoe->fip_packet_type.dev = netdev; |
| 325 | dev_add_pack(&fcoe->fip_packet_type); |
| 326 | |
| 327 | return 0; |
| 328 | } |
| 329 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 330 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 331 | * fcoe_interface_create() - Create a FCoE interface on a net device |
| 332 | * @netdev: The net device to create the FCoE interface on |
Joe Eykholt | 1dd454d | 2010-07-20 15:20:46 -0700 | [diff] [blame] | 333 | * @fip_mode: The mode to use for FIP |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 334 | * |
| 335 | * Returns: pointer to a struct fcoe_interface or NULL on error |
| 336 | */ |
Joe Eykholt | 1dd454d | 2010-07-20 15:20:46 -0700 | [diff] [blame] | 337 | static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev, |
| 338 | enum fip_state fip_mode) |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 339 | { |
| 340 | struct fcoe_interface *fcoe; |
john fastabend | 59d9251 | 2009-11-03 11:48:44 -0800 | [diff] [blame] | 341 | int err; |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 342 | |
Robert Love | 7287fb9 | 2011-01-28 16:03:47 -0800 | [diff] [blame] | 343 | if (!try_module_get(THIS_MODULE)) { |
| 344 | FCOE_NETDEV_DBG(netdev, |
| 345 | "Could not get a reference to the module\n"); |
| 346 | fcoe = ERR_PTR(-EBUSY); |
| 347 | goto out; |
| 348 | } |
| 349 | |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 350 | fcoe = kzalloc(sizeof(*fcoe), GFP_KERNEL); |
| 351 | if (!fcoe) { |
| 352 | FCOE_NETDEV_DBG(netdev, "Could not allocate fcoe structure\n"); |
Robert Love | 7287fb9 | 2011-01-28 16:03:47 -0800 | [diff] [blame] | 353 | fcoe = ERR_PTR(-ENOMEM); |
| 354 | goto out_nomod; |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 355 | } |
| 356 | |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 357 | dev_hold(netdev); |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 358 | kref_init(&fcoe->kref); |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 359 | |
| 360 | /* |
| 361 | * Initialize FIP. |
| 362 | */ |
Joe Eykholt | 1dd454d | 2010-07-20 15:20:46 -0700 | [diff] [blame] | 363 | fcoe_ctlr_init(&fcoe->ctlr, fip_mode); |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 364 | fcoe->ctlr.send = fcoe_fip_send; |
| 365 | fcoe->ctlr.update_mac = fcoe_update_src_mac; |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 366 | fcoe->ctlr.get_src_addr = fcoe_get_src_mac; |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 367 | |
john fastabend | 59d9251 | 2009-11-03 11:48:44 -0800 | [diff] [blame] | 368 | err = fcoe_interface_setup(fcoe, netdev); |
| 369 | if (err) { |
| 370 | fcoe_ctlr_destroy(&fcoe->ctlr); |
| 371 | kfree(fcoe); |
| 372 | dev_put(netdev); |
Robert Love | 7287fb9 | 2011-01-28 16:03:47 -0800 | [diff] [blame] | 373 | fcoe = ERR_PTR(err); |
| 374 | goto out_nomod; |
john fastabend | 59d9251 | 2009-11-03 11:48:44 -0800 | [diff] [blame] | 375 | } |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 376 | |
Robert Love | 7287fb9 | 2011-01-28 16:03:47 -0800 | [diff] [blame] | 377 | goto out; |
| 378 | |
| 379 | out_nomod: |
| 380 | module_put(THIS_MODULE); |
| 381 | out: |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 382 | return fcoe; |
| 383 | } |
| 384 | |
| 385 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 386 | * fcoe_interface_cleanup() - Clean up a FCoE interface |
| 387 | * @fcoe: The FCoE interface to be cleaned up |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 388 | * |
| 389 | * Caller must be holding the RTNL mutex |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 390 | */ |
| 391 | void fcoe_interface_cleanup(struct fcoe_interface *fcoe) |
| 392 | { |
| 393 | struct net_device *netdev = fcoe->netdev; |
| 394 | struct fcoe_ctlr *fip = &fcoe->ctlr; |
| 395 | u8 flogi_maddr[ETH_ALEN]; |
Yi Zou | b7a727f | 2009-10-21 16:28:03 -0700 | [diff] [blame] | 396 | const struct net_device_ops *ops; |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 397 | |
| 398 | /* |
| 399 | * Don't listen for Ethernet packets anymore. |
| 400 | * synchronize_net() ensures that the packet handlers are not running |
| 401 | * on another CPU. dev_remove_pack() would do that, this calls the |
| 402 | * unsyncronized version __dev_remove_pack() to avoid multiple delays. |
| 403 | */ |
| 404 | __dev_remove_pack(&fcoe->fcoe_packet_type); |
| 405 | __dev_remove_pack(&fcoe->fip_packet_type); |
| 406 | synchronize_net(); |
| 407 | |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 408 | /* Delete secondary MAC addresses */ |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 409 | memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); |
Jiri Pirko | a748ee2 | 2010-04-01 21:22:09 +0000 | [diff] [blame] | 410 | dev_uc_del(netdev, flogi_maddr); |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 411 | if (fip->spma) |
Jiri Pirko | a748ee2 | 2010-04-01 21:22:09 +0000 | [diff] [blame] | 412 | dev_uc_del(netdev, fip->ctl_src_addr); |
Joe Eykholt | e10f8c6 | 2010-07-20 15:20:30 -0700 | [diff] [blame] | 413 | if (fip->mode == FIP_MODE_VN2VN) { |
| 414 | dev_mc_del(netdev, FIP_ALL_VN2VN_MACS); |
| 415 | dev_mc_del(netdev, FIP_ALL_P2P_MACS); |
| 416 | } else |
| 417 | dev_mc_del(netdev, FIP_ALL_ENODE_MACS); |
Yi Zou | b7a727f | 2009-10-21 16:28:03 -0700 | [diff] [blame] | 418 | |
| 419 | /* Tell the LLD we are done w/ FCoE */ |
| 420 | ops = netdev->netdev_ops; |
| 421 | if (ops->ndo_fcoe_disable) { |
| 422 | if (ops->ndo_fcoe_disable(netdev)) |
| 423 | FCOE_NETDEV_DBG(netdev, "Failed to disable FCoE" |
| 424 | " specific feature for LLD.\n"); |
| 425 | } |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | /** |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 429 | * fcoe_interface_release() - fcoe_port kref release function |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 430 | * @kref: Embedded reference count in an fcoe_interface struct |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 431 | */ |
| 432 | static void fcoe_interface_release(struct kref *kref) |
| 433 | { |
| 434 | struct fcoe_interface *fcoe; |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 435 | struct net_device *netdev; |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 436 | |
| 437 | fcoe = container_of(kref, struct fcoe_interface, kref); |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 438 | netdev = fcoe->netdev; |
| 439 | /* tear-down the FCoE controller */ |
| 440 | fcoe_ctlr_destroy(&fcoe->ctlr); |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 441 | kfree(fcoe); |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 442 | dev_put(netdev); |
Robert Love | 7287fb9 | 2011-01-28 16:03:47 -0800 | [diff] [blame] | 443 | module_put(THIS_MODULE); |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 447 | * fcoe_interface_get() - Get a reference to a FCoE interface |
| 448 | * @fcoe: The FCoE interface to be held |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 449 | */ |
| 450 | static inline void fcoe_interface_get(struct fcoe_interface *fcoe) |
| 451 | { |
| 452 | kref_get(&fcoe->kref); |
| 453 | } |
| 454 | |
| 455 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 456 | * fcoe_interface_put() - Put a reference to a FCoE interface |
| 457 | * @fcoe: The FCoE interface to be released |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 458 | */ |
| 459 | static inline void fcoe_interface_put(struct fcoe_interface *fcoe) |
| 460 | { |
| 461 | kref_put(&fcoe->kref, fcoe_interface_release); |
| 462 | } |
| 463 | |
| 464 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 465 | * fcoe_fip_recv() - Handler for received FIP frames |
| 466 | * @skb: The receive skb |
| 467 | * @netdev: The associated net device |
| 468 | * @ptype: The packet_type structure which was used to register this handler |
| 469 | * @orig_dev: The original net_device the the skb was received on. |
| 470 | * (in case dev is a bond) |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 471 | * |
| 472 | * Returns: 0 for success |
| 473 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 474 | static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *netdev, |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 475 | struct packet_type *ptype, |
| 476 | struct net_device *orig_dev) |
| 477 | { |
Chris Leech | 259ad85 | 2009-08-25 13:59:41 -0700 | [diff] [blame] | 478 | struct fcoe_interface *fcoe; |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 479 | |
Chris Leech | 259ad85 | 2009-08-25 13:59:41 -0700 | [diff] [blame] | 480 | fcoe = container_of(ptype, struct fcoe_interface, fip_packet_type); |
Chris Leech | 3fe9a0b | 2009-08-25 13:59:46 -0700 | [diff] [blame] | 481 | fcoe_ctlr_recv(&fcoe->ctlr, skb); |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 482 | return 0; |
| 483 | } |
| 484 | |
| 485 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 486 | * fcoe_fip_send() - Send an Ethernet-encapsulated FIP frame |
| 487 | * @fip: The FCoE controller |
| 488 | * @skb: The FIP packet to be sent |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 489 | */ |
| 490 | static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb) |
| 491 | { |
Chris Leech | 3fe9a0b | 2009-08-25 13:59:46 -0700 | [diff] [blame] | 492 | skb->dev = fcoe_from_ctlr(fip)->netdev; |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 493 | dev_queue_xmit(skb); |
| 494 | } |
| 495 | |
| 496 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 497 | * fcoe_update_src_mac() - Update the Ethernet MAC filters |
| 498 | * @lport: The local port to update the source MAC on |
| 499 | * @addr: Unicast MAC address to add |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 500 | * |
| 501 | * Remove any previously-set unicast MAC filter. |
| 502 | * Add secondary FCoE MAC address filter for our OUI. |
| 503 | */ |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 504 | static void fcoe_update_src_mac(struct fc_lport *lport, u8 *addr) |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 505 | { |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 506 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 507 | struct fcoe_interface *fcoe = port->priv; |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 508 | |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 509 | rtnl_lock(); |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 510 | if (!is_zero_ether_addr(port->data_src_addr)) |
Jiri Pirko | a748ee2 | 2010-04-01 21:22:09 +0000 | [diff] [blame] | 511 | dev_uc_del(fcoe->netdev, port->data_src_addr); |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 512 | if (!is_zero_ether_addr(addr)) |
Jiri Pirko | a748ee2 | 2010-04-01 21:22:09 +0000 | [diff] [blame] | 513 | dev_uc_add(fcoe->netdev, addr); |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 514 | memcpy(port->data_src_addr, addr, ETH_ALEN); |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 515 | rtnl_unlock(); |
| 516 | } |
| 517 | |
| 518 | /** |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 519 | * fcoe_get_src_mac() - return the Ethernet source address for an lport |
| 520 | * @lport: libfc lport |
| 521 | */ |
| 522 | static u8 *fcoe_get_src_mac(struct fc_lport *lport) |
| 523 | { |
| 524 | struct fcoe_port *port = lport_priv(lport); |
| 525 | |
| 526 | return port->data_src_addr; |
| 527 | } |
| 528 | |
| 529 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 530 | * fcoe_lport_config() - Set up a local port |
| 531 | * @lport: The local port to be setup |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 532 | * |
| 533 | * Returns: 0 for success |
| 534 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 535 | static int fcoe_lport_config(struct fc_lport *lport) |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 536 | { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 537 | lport->link_up = 0; |
| 538 | lport->qfull = 0; |
| 539 | lport->max_retry_count = 3; |
| 540 | lport->max_rport_retry_count = 3; |
| 541 | lport->e_d_tov = 2 * 1000; /* FC-FS default */ |
| 542 | lport->r_a_tov = 2 * 2 * 1000; |
| 543 | lport->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS | |
| 544 | FCP_SPPF_RETRY | FCP_SPPF_CONF_COMPL); |
| 545 | lport->does_npiv = 1; |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 546 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 547 | fc_lport_init_stats(lport); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 548 | |
| 549 | /* lport fc_lport related configuration */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 550 | fc_lport_config(lport); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 551 | |
| 552 | /* offload related configuration */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 553 | lport->crc_offload = 0; |
| 554 | lport->seq_offload = 0; |
| 555 | lport->lro_enabled = 0; |
| 556 | lport->lro_xid = 0; |
| 557 | lport->lso_max = 0; |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 558 | |
| 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | /** |
Yi Zou | dcece41 | 2009-11-20 15:22:21 -0800 | [diff] [blame] | 563 | * fcoe_get_wwn() - Get the world wide name from LLD if it supports it |
| 564 | * @netdev: the associated net device |
| 565 | * @wwn: the output WWN |
| 566 | * @type: the type of WWN (WWPN or WWNN) |
| 567 | * |
| 568 | * Returns: 0 for success |
| 569 | */ |
| 570 | static int fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type) |
| 571 | { |
| 572 | const struct net_device_ops *ops = netdev->netdev_ops; |
| 573 | |
| 574 | if (ops->ndo_fcoe_get_wwn) |
| 575 | return ops->ndo_fcoe_get_wwn(netdev, wwn, type); |
| 576 | return -EINVAL; |
| 577 | } |
| 578 | |
| 579 | /** |
Yi Zou | 54a5b21 | 2010-07-20 15:21:17 -0700 | [diff] [blame] | 580 | * fcoe_netdev_features_change - Updates the lport's offload flags based |
| 581 | * on the LLD netdev's FCoE feature flags |
| 582 | */ |
| 583 | static void fcoe_netdev_features_change(struct fc_lport *lport, |
| 584 | struct net_device *netdev) |
| 585 | { |
| 586 | mutex_lock(&lport->lp_mutex); |
| 587 | |
| 588 | if (netdev->features & NETIF_F_SG) |
| 589 | lport->sg_supp = 1; |
| 590 | else |
| 591 | lport->sg_supp = 0; |
| 592 | |
| 593 | if (netdev->features & NETIF_F_FCOE_CRC) { |
| 594 | lport->crc_offload = 1; |
| 595 | FCOE_NETDEV_DBG(netdev, "Supports FCCRC offload\n"); |
| 596 | } else { |
| 597 | lport->crc_offload = 0; |
| 598 | } |
| 599 | |
| 600 | if (netdev->features & NETIF_F_FSO) { |
| 601 | lport->seq_offload = 1; |
| 602 | lport->lso_max = netdev->gso_max_size; |
| 603 | FCOE_NETDEV_DBG(netdev, "Supports LSO for max len 0x%x\n", |
| 604 | lport->lso_max); |
| 605 | } else { |
| 606 | lport->seq_offload = 0; |
| 607 | lport->lso_max = 0; |
| 608 | } |
| 609 | |
| 610 | if (netdev->fcoe_ddp_xid) { |
| 611 | lport->lro_enabled = 1; |
| 612 | lport->lro_xid = netdev->fcoe_ddp_xid; |
| 613 | FCOE_NETDEV_DBG(netdev, "Supports LRO for max xid 0x%x\n", |
| 614 | lport->lro_xid); |
| 615 | } else { |
| 616 | lport->lro_enabled = 0; |
| 617 | lport->lro_xid = 0; |
| 618 | } |
| 619 | |
| 620 | mutex_unlock(&lport->lp_mutex); |
| 621 | } |
| 622 | |
| 623 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 624 | * fcoe_netdev_config() - Set up net devive for SW FCoE |
| 625 | * @lport: The local port that is associated with the net device |
| 626 | * @netdev: The associated net device |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 627 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 628 | * Must be called after fcoe_lport_config() as it will use local port mutex |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 629 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 630 | * Returns: 0 for success |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 631 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 632 | static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev) |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 633 | { |
| 634 | u32 mfs; |
| 635 | u64 wwnn, wwpn; |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 636 | struct fcoe_interface *fcoe; |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 637 | struct fcoe_port *port; |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 638 | |
| 639 | /* Setup lport private data to point to fcoe softc */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 640 | port = lport_priv(lport); |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 641 | fcoe = port->priv; |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 642 | |
| 643 | /* |
| 644 | * Determine max frame size based on underlying device and optional |
| 645 | * user-configured limit. If the MFS is too low, fcoe_link_ok() |
| 646 | * will return 0, so do this first. |
| 647 | */ |
Yi Zou | 7221d7e | 2009-10-21 16:27:52 -0700 | [diff] [blame] | 648 | mfs = netdev->mtu; |
| 649 | if (netdev->features & NETIF_F_FCOE_MTU) { |
| 650 | mfs = FCOE_MTU; |
| 651 | FCOE_NETDEV_DBG(netdev, "Supports FCOE_MTU of %d bytes\n", mfs); |
| 652 | } |
| 653 | mfs -= (sizeof(struct fcoe_hdr) + sizeof(struct fcoe_crc_eof)); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 654 | if (fc_set_mfs(lport, mfs)) |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 655 | return -EINVAL; |
| 656 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 657 | /* offload features support */ |
Yi Zou | 54a5b21 | 2010-07-20 15:21:17 -0700 | [diff] [blame] | 658 | fcoe_netdev_features_change(lport, netdev); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 659 | |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 660 | skb_queue_head_init(&port->fcoe_pending_queue); |
| 661 | port->fcoe_pending_queue_active = 0; |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 662 | setup_timer(&port->timer, fcoe_queue_timer, (unsigned long)lport); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 663 | |
Robert Love | 5e4f8fe | 2010-05-07 15:18:35 -0700 | [diff] [blame] | 664 | fcoe_link_speed_update(lport); |
| 665 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 666 | if (!lport->vport) { |
Yi Zou | dcece41 | 2009-11-20 15:22:21 -0800 | [diff] [blame] | 667 | if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN)) |
| 668 | wwnn = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, 1, 0); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 669 | fc_set_wwnn(lport, wwnn); |
Yi Zou | dcece41 | 2009-11-20 15:22:21 -0800 | [diff] [blame] | 670 | if (fcoe_get_wwn(netdev, &wwpn, NETDEV_FCOE_WWPN)) |
| 671 | wwpn = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, |
Vasu Dev | cf4aebca | 2010-07-20 15:21:22 -0700 | [diff] [blame] | 672 | 2, 0); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 673 | fc_set_wwpn(lport, wwpn); |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 674 | } |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 675 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 676 | return 0; |
| 677 | } |
| 678 | |
| 679 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 680 | * fcoe_shost_config() - Set up the SCSI host associated with a local port |
| 681 | * @lport: The local port |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 682 | * @dev: The device associated with the SCSI host |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 683 | * |
| 684 | * Must be called after fcoe_lport_config() and fcoe_netdev_config() |
| 685 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 686 | * Returns: 0 for success |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 687 | */ |
Vasu Dev | 8ba00a4 | 2010-04-09 14:22:54 -0700 | [diff] [blame] | 688 | static int fcoe_shost_config(struct fc_lport *lport, struct device *dev) |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 689 | { |
| 690 | int rc = 0; |
| 691 | |
| 692 | /* lport scsi host config */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 693 | lport->host->max_lun = FCOE_MAX_LUN; |
| 694 | lport->host->max_id = FCOE_MAX_FCP_TARGET; |
| 695 | lport->host->max_channel = 0; |
Vasu Dev | da87bfa | 2010-04-09 14:22:59 -0700 | [diff] [blame] | 696 | lport->host->max_cmd_len = FCOE_MAX_CMD_LEN; |
| 697 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 698 | if (lport->vport) |
Yi Zou | 8ca86f8 | 2011-01-28 16:05:11 -0800 | [diff] [blame] | 699 | lport->host->transportt = fcoe_vport_scsi_transport; |
Chris Leech | e9084bb | 2009-11-03 11:46:34 -0800 | [diff] [blame] | 700 | else |
Yi Zou | 8ca86f8 | 2011-01-28 16:05:11 -0800 | [diff] [blame] | 701 | lport->host->transportt = fcoe_nport_scsi_transport; |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 702 | |
| 703 | /* add the new host to the SCSI-ml */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 704 | rc = scsi_add_host(lport->host, dev); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 705 | if (rc) { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 706 | FCOE_NETDEV_DBG(fcoe_netdev(lport), "fcoe_shost_config: " |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 707 | "error on scsi_add_host\n"); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 708 | return rc; |
| 709 | } |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 710 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 711 | if (!lport->vport) |
Alexey Dobriyan | 4be929b | 2010-05-24 14:33:03 -0700 | [diff] [blame] | 712 | fc_host_max_npiv_vports(lport->host) = USHRT_MAX; |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 713 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 714 | snprintf(fc_host_symbolic_name(lport->host), FC_SYMBOLIC_NAME_SIZE, |
Chris Leech | 5baa17c | 2009-11-03 11:46:56 -0800 | [diff] [blame] | 715 | "%s v%s over %s", FCOE_NAME, FCOE_VERSION, |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 716 | fcoe_netdev(lport)->name); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 717 | |
| 718 | return 0; |
| 719 | } |
| 720 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 721 | /** |
| 722 | * fcoe_oem_match() - The match routine for the offloaded exchange manager |
| 723 | * @fp: The I/O frame |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 724 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 725 | * This routine will be associated with an exchange manager (EM). When |
| 726 | * the libfc exchange handling code is looking for an EM to use it will |
| 727 | * call this routine and pass it the frame that it wishes to send. This |
| 728 | * routine will return True if the associated EM is to be used and False |
| 729 | * if the echange code should continue looking for an EM. |
| 730 | * |
| 731 | * The offload EM that this routine is associated with will handle any |
| 732 | * packets that are for SCSI read requests. |
| 733 | * |
| 734 | * Returns: True for read types I/O, otherwise returns false. |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 735 | */ |
| 736 | bool fcoe_oem_match(struct fc_frame *fp) |
| 737 | { |
Yi Zou | 05cc739 | 2009-08-25 13:59:03 -0700 | [diff] [blame] | 738 | return fc_fcp_is_read(fr_fsp(fp)) && |
| 739 | (fr_fsp(fp)->data_len > fcoe_ddp_min); |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 740 | } |
| 741 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 742 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 743 | * fcoe_em_config() - Allocate and configure an exchange manager |
| 744 | * @lport: The local port that the new EM will be associated with |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 745 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 746 | * Returns: 0 on success |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 747 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 748 | static inline int fcoe_em_config(struct fc_lport *lport) |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 749 | { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 750 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 751 | struct fcoe_interface *fcoe = port->priv; |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 752 | struct fcoe_interface *oldfcoe = NULL; |
Vasu Dev | 1d1b88d | 2009-07-29 17:05:45 -0700 | [diff] [blame] | 753 | struct net_device *old_real_dev, *cur_real_dev; |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 754 | u16 min_xid = FCOE_MIN_XID; |
| 755 | u16 max_xid = FCOE_MAX_XID; |
| 756 | |
| 757 | /* |
| 758 | * Check if need to allocate an em instance for |
| 759 | * offload exchange ids to be shared across all VN_PORTs/lport. |
| 760 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 761 | if (!lport->lro_enabled || !lport->lro_xid || |
| 762 | (lport->lro_xid >= max_xid)) { |
| 763 | lport->lro_xid = 0; |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 764 | goto skip_oem; |
| 765 | } |
| 766 | |
| 767 | /* |
| 768 | * Reuse existing offload em instance in case |
Vasu Dev | 1d1b88d | 2009-07-29 17:05:45 -0700 | [diff] [blame] | 769 | * it is already allocated on real eth device |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 770 | */ |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 771 | if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN) |
| 772 | cur_real_dev = vlan_dev_real_dev(fcoe->netdev); |
Vasu Dev | 1d1b88d | 2009-07-29 17:05:45 -0700 | [diff] [blame] | 773 | else |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 774 | cur_real_dev = fcoe->netdev; |
Vasu Dev | 1d1b88d | 2009-07-29 17:05:45 -0700 | [diff] [blame] | 775 | |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 776 | list_for_each_entry(oldfcoe, &fcoe_hostlist, list) { |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 777 | if (oldfcoe->netdev->priv_flags & IFF_802_1Q_VLAN) |
| 778 | old_real_dev = vlan_dev_real_dev(oldfcoe->netdev); |
Vasu Dev | 1d1b88d | 2009-07-29 17:05:45 -0700 | [diff] [blame] | 779 | else |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 780 | old_real_dev = oldfcoe->netdev; |
Vasu Dev | 1d1b88d | 2009-07-29 17:05:45 -0700 | [diff] [blame] | 781 | |
| 782 | if (cur_real_dev == old_real_dev) { |
Chris Leech | 991cbb6 | 2009-08-25 13:59:51 -0700 | [diff] [blame] | 783 | fcoe->oem = oldfcoe->oem; |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 784 | break; |
| 785 | } |
| 786 | } |
| 787 | |
Chris Leech | 991cbb6 | 2009-08-25 13:59:51 -0700 | [diff] [blame] | 788 | if (fcoe->oem) { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 789 | if (!fc_exch_mgr_add(lport, fcoe->oem, fcoe_oem_match)) { |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 790 | printk(KERN_ERR "fcoe_em_config: failed to add " |
| 791 | "offload em:%p on interface:%s\n", |
Chris Leech | 991cbb6 | 2009-08-25 13:59:51 -0700 | [diff] [blame] | 792 | fcoe->oem, fcoe->netdev->name); |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 793 | return -ENOMEM; |
| 794 | } |
| 795 | } else { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 796 | fcoe->oem = fc_exch_mgr_alloc(lport, FC_CLASS_3, |
| 797 | FCOE_MIN_XID, lport->lro_xid, |
| 798 | fcoe_oem_match); |
Chris Leech | 991cbb6 | 2009-08-25 13:59:51 -0700 | [diff] [blame] | 799 | if (!fcoe->oem) { |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 800 | printk(KERN_ERR "fcoe_em_config: failed to allocate " |
| 801 | "em for offload exches on interface:%s\n", |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 802 | fcoe->netdev->name); |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 803 | return -ENOMEM; |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | /* |
| 808 | * Exclude offload EM xid range from next EM xid range. |
| 809 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 810 | min_xid += lport->lro_xid + 1; |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 811 | |
| 812 | skip_oem: |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 813 | if (!fc_exch_mgr_alloc(lport, FC_CLASS_3, min_xid, max_xid, NULL)) { |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 814 | printk(KERN_ERR "fcoe_em_config: failed to " |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 815 | "allocate em on interface %s\n", fcoe->netdev->name); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 816 | return -ENOMEM; |
Vasu Dev | d717968 | 2009-07-29 17:05:21 -0700 | [diff] [blame] | 817 | } |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 818 | |
| 819 | return 0; |
| 820 | } |
| 821 | |
| 822 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 823 | * fcoe_if_destroy() - Tear down a SW FCoE instance |
| 824 | * @lport: The local port to be destroyed |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 825 | * |
| 826 | * Locking: must be called with the RTNL mutex held and RTNL mutex |
| 827 | * needed to be dropped by this function since not dropping RTNL |
| 828 | * would cause circular locking warning on synchronous fip worker |
| 829 | * cancelling thru fcoe_interface_put invoked by this function. |
| 830 | * |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 831 | */ |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 832 | static void fcoe_if_destroy(struct fc_lport *lport) |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 833 | { |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 834 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 835 | struct fcoe_interface *fcoe = port->priv; |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 836 | struct net_device *netdev = fcoe->netdev; |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 837 | |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 838 | FCOE_NETDEV_DBG(netdev, "Destroying interface\n"); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 839 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 840 | /* Logout of the fabric */ |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 841 | fc_fabric_logoff(lport); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 842 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 843 | /* Cleanup the fc_lport */ |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 844 | fc_lport_destroy(lport); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 845 | |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 846 | /* Stop the transmit retry timer */ |
| 847 | del_timer_sync(&port->timer); |
| 848 | |
| 849 | /* Free existing transmit skbs */ |
| 850 | fcoe_clean_pending_queue(lport); |
| 851 | |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 852 | if (!is_zero_ether_addr(port->data_src_addr)) |
Jiri Pirko | a748ee2 | 2010-04-01 21:22:09 +0000 | [diff] [blame] | 853 | dev_uc_del(netdev, port->data_src_addr); |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 854 | rtnl_unlock(); |
| 855 | |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 856 | /* receives may not be stopped until after this */ |
| 857 | fcoe_interface_put(fcoe); |
| 858 | |
| 859 | /* Free queued packets for the per-CPU receive threads */ |
| 860 | fcoe_percpu_clean(lport); |
| 861 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 862 | /* Detach from the scsi-ml */ |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 863 | fc_remove_host(lport->host); |
| 864 | scsi_remove_host(lport->host); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 865 | |
Yi Zou | 80e736f | 2010-11-30 16:18:07 -0800 | [diff] [blame] | 866 | /* Destroy lport scsi_priv */ |
| 867 | fc_fcp_destroy(lport); |
| 868 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 869 | /* There are no more rports or I/O, free the EM */ |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 870 | fc_exch_mgr_free(lport); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 871 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 872 | /* Free memory used by statistical counters */ |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 873 | fc_lport_free_stats(lport); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 874 | |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 875 | /* Release the Scsi_Host */ |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 876 | scsi_host_put(lport->host); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 877 | } |
| 878 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 879 | /** |
| 880 | * fcoe_ddp_setup() - Call a LLD's ddp_setup through the net device |
| 881 | * @lport: The local port to setup DDP for |
| 882 | * @xid: The exchange ID for this DDP transfer |
| 883 | * @sgl: The scatterlist describing this transfer |
| 884 | * @sgc: The number of sg items |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 885 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 886 | * Returns: 0 if the DDP context was not configured |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 887 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 888 | static int fcoe_ddp_setup(struct fc_lport *lport, u16 xid, |
| 889 | struct scatterlist *sgl, unsigned int sgc) |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 890 | { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 891 | struct net_device *netdev = fcoe_netdev(lport); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 892 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 893 | if (netdev->netdev_ops->ndo_fcoe_ddp_setup) |
| 894 | return netdev->netdev_ops->ndo_fcoe_ddp_setup(netdev, |
| 895 | xid, sgl, |
| 896 | sgc); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 897 | |
| 898 | return 0; |
| 899 | } |
| 900 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 901 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 902 | * fcoe_ddp_done() - Call a LLD's ddp_done through the net device |
| 903 | * @lport: The local port to complete DDP on |
| 904 | * @xid: The exchange ID for this DDP transfer |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 905 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 906 | * Returns: the length of data that have been completed by DDP |
| 907 | */ |
| 908 | static int fcoe_ddp_done(struct fc_lport *lport, u16 xid) |
| 909 | { |
| 910 | struct net_device *netdev = fcoe_netdev(lport); |
| 911 | |
| 912 | if (netdev->netdev_ops->ndo_fcoe_ddp_done) |
| 913 | return netdev->netdev_ops->ndo_fcoe_ddp_done(netdev, xid); |
| 914 | return 0; |
| 915 | } |
| 916 | |
| 917 | /** |
| 918 | * fcoe_if_create() - Create a FCoE instance on an interface |
| 919 | * @fcoe: The FCoE interface to create a local port on |
| 920 | * @parent: The device pointer to be the parent in sysfs for the SCSI host |
| 921 | * @npiv: Indicates if the port is a vport or not |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 922 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 923 | * Creates a fc_lport instance and a Scsi_Host instance and configure them. |
| 924 | * |
| 925 | * Returns: The allocated fc_lport or an error pointer |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 926 | */ |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 927 | static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe, |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 928 | struct device *parent, int npiv) |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 929 | { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 930 | struct net_device *netdev = fcoe->netdev; |
Vasu Dev | 72fa396 | 2011-02-25 15:03:01 -0800 | [diff] [blame^] | 931 | struct fc_lport *lport, *n_port; |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 932 | struct fcoe_port *port; |
Vasu Dev | 72fa396 | 2011-02-25 15:03:01 -0800 | [diff] [blame^] | 933 | struct Scsi_Host *shost; |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 934 | int rc; |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 935 | /* |
| 936 | * parent is only a vport if npiv is 1, |
| 937 | * but we'll only use vport in that case so go ahead and set it |
| 938 | */ |
| 939 | struct fc_vport *vport = dev_to_vport(parent); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 940 | |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 941 | FCOE_NETDEV_DBG(netdev, "Create Interface\n"); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 942 | |
Vasu Dev | 72fa396 | 2011-02-25 15:03:01 -0800 | [diff] [blame^] | 943 | if (!npiv) |
| 944 | lport = libfc_host_alloc(&fcoe_shost_template, sizeof(*port)); |
| 945 | else |
| 946 | lport = libfc_vport_create(vport, sizeof(*port)); |
| 947 | |
Chris Leech | 8622196 | 2009-11-03 11:46:08 -0800 | [diff] [blame] | 948 | if (!lport) { |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 949 | FCOE_NETDEV_DBG(netdev, "Could not allocate host structure\n"); |
| 950 | rc = -ENOMEM; |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 951 | goto out; |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 952 | } |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 953 | port = lport_priv(lport); |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 954 | port->lport = lport; |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 955 | port->priv = fcoe; |
| 956 | port->max_queue_depth = FCOE_MAX_QUEUE_DEPTH; |
| 957 | port->min_queue_depth = FCOE_MIN_QUEUE_DEPTH; |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 958 | INIT_WORK(&port->destroy_work, fcoe_destroy_work); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 959 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 960 | /* configure a fc_lport including the exchange manager */ |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 961 | rc = fcoe_lport_config(lport); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 962 | if (rc) { |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 963 | FCOE_NETDEV_DBG(netdev, "Could not configure lport for the " |
| 964 | "interface\n"); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 965 | goto out_host_put; |
| 966 | } |
| 967 | |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 968 | if (npiv) { |
Chris Leech | 9f8f3aa | 2010-04-09 14:23:16 -0700 | [diff] [blame] | 969 | FCOE_NETDEV_DBG(netdev, "Setting vport names, " |
| 970 | "%16.16llx %16.16llx\n", |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 971 | vport->node_name, vport->port_name); |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 972 | fc_set_wwnn(lport, vport->node_name); |
| 973 | fc_set_wwpn(lport, vport->port_name); |
| 974 | } |
| 975 | |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 976 | /* configure lport network properties */ |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 977 | rc = fcoe_netdev_config(lport, netdev); |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 978 | if (rc) { |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 979 | FCOE_NETDEV_DBG(netdev, "Could not configure netdev for the " |
| 980 | "interface\n"); |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 981 | goto out_lp_destroy; |
Vasu Dev | ab6b85c | 2009-05-17 12:33:08 +0000 | [diff] [blame] | 982 | } |
Joe Eykholt | 97c8389 | 2009-03-17 11:42:40 -0700 | [diff] [blame] | 983 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 984 | /* configure lport scsi host properties */ |
Vasu Dev | 8ba00a4 | 2010-04-09 14:22:54 -0700 | [diff] [blame] | 985 | rc = fcoe_shost_config(lport, parent); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 986 | if (rc) { |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 987 | FCOE_NETDEV_DBG(netdev, "Could not configure shost for the " |
| 988 | "interface\n"); |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 989 | goto out_lp_destroy; |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 990 | } |
| 991 | |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 992 | /* Initialize the library */ |
Joe Eykholt | e10f8c6 | 2010-07-20 15:20:30 -0700 | [diff] [blame] | 993 | rc = fcoe_libfc_config(lport, &fcoe->ctlr, &fcoe_libfc_fcn_templ, 1); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 994 | if (rc) { |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 995 | FCOE_NETDEV_DBG(netdev, "Could not configure libfc for the " |
| 996 | "interface\n"); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 997 | goto out_lp_destroy; |
| 998 | } |
| 999 | |
Vasu Dev | 72fa396 | 2011-02-25 15:03:01 -0800 | [diff] [blame^] | 1000 | /* |
| 1001 | * fcoe_em_alloc() and fcoe_hostlist_add() both |
| 1002 | * need to be atomic with respect to other changes to the |
| 1003 | * hostlist since fcoe_em_alloc() looks for an existing EM |
| 1004 | * instance on host list updated by fcoe_hostlist_add(). |
| 1005 | * |
| 1006 | * This is currently handled through the fcoe_config_mutex |
| 1007 | * begin held. |
| 1008 | */ |
| 1009 | if (!npiv) |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 1010 | /* lport exch manager allocation */ |
| 1011 | rc = fcoe_em_config(lport); |
Vasu Dev | 72fa396 | 2011-02-25 15:03:01 -0800 | [diff] [blame^] | 1012 | else { |
| 1013 | shost = vport_to_shost(vport); |
| 1014 | n_port = shost_priv(shost); |
| 1015 | rc = fc_exch_mgr_list_clone(n_port, lport); |
| 1016 | } |
| 1017 | |
| 1018 | if (rc) { |
| 1019 | FCOE_NETDEV_DBG(netdev, "Could not configure the EM\n"); |
| 1020 | goto out_lp_destroy; |
Vasu Dev | 9631609 | 2009-07-29 17:05:00 -0700 | [diff] [blame] | 1021 | } |
| 1022 | |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 1023 | fcoe_interface_get(fcoe); |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 1024 | return lport; |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 1025 | |
| 1026 | out_lp_destroy: |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 1027 | fc_exch_mgr_free(lport); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 1028 | out_host_put: |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 1029 | scsi_host_put(lport->host); |
| 1030 | out: |
| 1031 | return ERR_PTR(rc); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1035 | * fcoe_if_init() - Initialization routine for fcoe.ko |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 1036 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1037 | * Attaches the SW FCoE transport to the FC transport |
| 1038 | * |
| 1039 | * Returns: 0 on success |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 1040 | */ |
| 1041 | static int __init fcoe_if_init(void) |
| 1042 | { |
| 1043 | /* attach to scsi transport */ |
Yi Zou | 8ca86f8 | 2011-01-28 16:05:11 -0800 | [diff] [blame] | 1044 | fcoe_nport_scsi_transport = |
| 1045 | fc_attach_transport(&fcoe_nport_fc_functions); |
| 1046 | fcoe_vport_scsi_transport = |
| 1047 | fc_attach_transport(&fcoe_vport_fc_functions); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 1048 | |
Yi Zou | 8ca86f8 | 2011-01-28 16:05:11 -0800 | [diff] [blame] | 1049 | if (!fcoe_nport_scsi_transport) { |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 1050 | printk(KERN_ERR "fcoe: Failed to attach to the FC transport\n"); |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 1051 | return -ENODEV; |
| 1052 | } |
| 1053 | |
| 1054 | return 0; |
| 1055 | } |
| 1056 | |
| 1057 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1058 | * fcoe_if_exit() - Tear down fcoe.ko |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 1059 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1060 | * Detaches the SW FCoE transport from the FC transport |
| 1061 | * |
| 1062 | * Returns: 0 on success |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 1063 | */ |
| 1064 | int __exit fcoe_if_exit(void) |
| 1065 | { |
Yi Zou | 8ca86f8 | 2011-01-28 16:05:11 -0800 | [diff] [blame] | 1066 | fc_release_transport(fcoe_nport_scsi_transport); |
| 1067 | fc_release_transport(fcoe_vport_scsi_transport); |
| 1068 | fcoe_nport_scsi_transport = NULL; |
| 1069 | fcoe_vport_scsi_transport = NULL; |
Vasu Dev | 7f34914 | 2009-03-27 09:06:31 -0700 | [diff] [blame] | 1070 | return 0; |
| 1071 | } |
| 1072 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1073 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1074 | * fcoe_percpu_thread_create() - Create a receive thread for an online CPU |
| 1075 | * @cpu: The CPU index of the CPU to create a receive thread for |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1076 | */ |
| 1077 | static void fcoe_percpu_thread_create(unsigned int cpu) |
| 1078 | { |
| 1079 | struct fcoe_percpu_s *p; |
| 1080 | struct task_struct *thread; |
| 1081 | |
| 1082 | p = &per_cpu(fcoe_percpu, cpu); |
| 1083 | |
| 1084 | thread = kthread_create(fcoe_percpu_receive_thread, |
| 1085 | (void *)p, "fcoethread/%d", cpu); |
| 1086 | |
Joe Eykholt | e7a5199 | 2009-08-25 14:04:08 -0700 | [diff] [blame] | 1087 | if (likely(!IS_ERR(thread))) { |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1088 | kthread_bind(thread, cpu); |
| 1089 | wake_up_process(thread); |
| 1090 | |
| 1091 | spin_lock_bh(&p->fcoe_rx_list.lock); |
| 1092 | p->thread = thread; |
| 1093 | spin_unlock_bh(&p->fcoe_rx_list.lock); |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1098 | * fcoe_percpu_thread_destroy() - Remove the receive thread of a CPU |
| 1099 | * @cpu: The CPU index of the CPU whose receive thread is to be destroyed |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1100 | * |
| 1101 | * Destroys a per-CPU Rx thread. Any pending skbs are moved to the |
| 1102 | * current CPU's Rx thread. If the thread being destroyed is bound to |
| 1103 | * the CPU processing this context the skbs will be freed. |
| 1104 | */ |
| 1105 | static void fcoe_percpu_thread_destroy(unsigned int cpu) |
| 1106 | { |
| 1107 | struct fcoe_percpu_s *p; |
| 1108 | struct task_struct *thread; |
| 1109 | struct page *crc_eof; |
| 1110 | struct sk_buff *skb; |
| 1111 | #ifdef CONFIG_SMP |
| 1112 | struct fcoe_percpu_s *p0; |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1113 | unsigned targ_cpu = get_cpu(); |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1114 | #endif /* CONFIG_SMP */ |
| 1115 | |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 1116 | FCOE_DBG("Destroying receive thread for CPU %d\n", cpu); |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1117 | |
| 1118 | /* Prevent any new skbs from being queued for this CPU. */ |
| 1119 | p = &per_cpu(fcoe_percpu, cpu); |
| 1120 | spin_lock_bh(&p->fcoe_rx_list.lock); |
| 1121 | thread = p->thread; |
| 1122 | p->thread = NULL; |
| 1123 | crc_eof = p->crc_eof_page; |
| 1124 | p->crc_eof_page = NULL; |
| 1125 | p->crc_eof_offset = 0; |
| 1126 | spin_unlock_bh(&p->fcoe_rx_list.lock); |
| 1127 | |
| 1128 | #ifdef CONFIG_SMP |
| 1129 | /* |
| 1130 | * Don't bother moving the skb's if this context is running |
| 1131 | * on the same CPU that is having its thread destroyed. This |
| 1132 | * can easily happen when the module is removed. |
| 1133 | */ |
| 1134 | if (cpu != targ_cpu) { |
| 1135 | p0 = &per_cpu(fcoe_percpu, targ_cpu); |
| 1136 | spin_lock_bh(&p0->fcoe_rx_list.lock); |
| 1137 | if (p0->thread) { |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 1138 | FCOE_DBG("Moving frames from CPU %d to CPU %d\n", |
| 1139 | cpu, targ_cpu); |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1140 | |
| 1141 | while ((skb = __skb_dequeue(&p->fcoe_rx_list)) != NULL) |
| 1142 | __skb_queue_tail(&p0->fcoe_rx_list, skb); |
| 1143 | spin_unlock_bh(&p0->fcoe_rx_list.lock); |
| 1144 | } else { |
| 1145 | /* |
| 1146 | * The targeted CPU is not initialized and cannot accept |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1147 | * new skbs. Unlock the targeted CPU and drop the skbs |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1148 | * on the CPU that is going offline. |
| 1149 | */ |
| 1150 | while ((skb = __skb_dequeue(&p->fcoe_rx_list)) != NULL) |
| 1151 | kfree_skb(skb); |
| 1152 | spin_unlock_bh(&p0->fcoe_rx_list.lock); |
| 1153 | } |
| 1154 | } else { |
| 1155 | /* |
| 1156 | * This scenario occurs when the module is being removed |
| 1157 | * and all threads are being destroyed. skbs will continue |
| 1158 | * to be shifted from the CPU thread that is being removed |
| 1159 | * to the CPU thread associated with the CPU that is processing |
| 1160 | * the module removal. Once there is only one CPU Rx thread it |
| 1161 | * will reach this case and we will drop all skbs and later |
| 1162 | * stop the thread. |
| 1163 | */ |
| 1164 | spin_lock_bh(&p->fcoe_rx_list.lock); |
| 1165 | while ((skb = __skb_dequeue(&p->fcoe_rx_list)) != NULL) |
| 1166 | kfree_skb(skb); |
| 1167 | spin_unlock_bh(&p->fcoe_rx_list.lock); |
| 1168 | } |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1169 | put_cpu(); |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1170 | #else |
| 1171 | /* |
Chris Leech | dd3fd72 | 2009-04-21 16:27:36 -0700 | [diff] [blame] | 1172 | * This a non-SMP scenario where the singular Rx thread is |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1173 | * being removed. Free all skbs and stop the thread. |
| 1174 | */ |
| 1175 | spin_lock_bh(&p->fcoe_rx_list.lock); |
| 1176 | while ((skb = __skb_dequeue(&p->fcoe_rx_list)) != NULL) |
| 1177 | kfree_skb(skb); |
| 1178 | spin_unlock_bh(&p->fcoe_rx_list.lock); |
| 1179 | #endif |
| 1180 | |
| 1181 | if (thread) |
| 1182 | kthread_stop(thread); |
| 1183 | |
| 1184 | if (crc_eof) |
| 1185 | put_page(crc_eof); |
| 1186 | } |
| 1187 | |
| 1188 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1189 | * fcoe_cpu_callback() - Handler for CPU hotplug events |
| 1190 | * @nfb: The callback data block |
| 1191 | * @action: The event triggering the callback |
| 1192 | * @hcpu: The index of the CPU that the event is for |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1193 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1194 | * This creates or destroys per-CPU data for fcoe |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1195 | * |
| 1196 | * Returns NOTIFY_OK always. |
| 1197 | */ |
| 1198 | static int fcoe_cpu_callback(struct notifier_block *nfb, |
| 1199 | unsigned long action, void *hcpu) |
| 1200 | { |
| 1201 | unsigned cpu = (unsigned long)hcpu; |
| 1202 | |
| 1203 | switch (action) { |
| 1204 | case CPU_ONLINE: |
| 1205 | case CPU_ONLINE_FROZEN: |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 1206 | FCOE_DBG("CPU %x online: Create Rx thread\n", cpu); |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1207 | fcoe_percpu_thread_create(cpu); |
| 1208 | break; |
| 1209 | case CPU_DEAD: |
| 1210 | case CPU_DEAD_FROZEN: |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 1211 | FCOE_DBG("CPU %x offline: Remove Rx thread\n", cpu); |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1212 | fcoe_percpu_thread_destroy(cpu); |
| 1213 | break; |
| 1214 | default: |
| 1215 | break; |
| 1216 | } |
| 1217 | return NOTIFY_OK; |
| 1218 | } |
| 1219 | |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1220 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1221 | * fcoe_rcv() - Receive packets from a net device |
| 1222 | * @skb: The received packet |
| 1223 | * @netdev: The net device that the packet was received on |
| 1224 | * @ptype: The packet type context |
| 1225 | * @olddev: The last device net device |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1226 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1227 | * This routine is called by NET_RX_SOFTIRQ. It receives a packet, builds a |
| 1228 | * FC frame and passes the frame to libfc. |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1229 | * |
| 1230 | * Returns: 0 for success |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 1231 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1232 | int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1233 | struct packet_type *ptype, struct net_device *olddev) |
| 1234 | { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1235 | struct fc_lport *lport; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1236 | struct fcoe_rcv_info *fr; |
Chris Leech | 259ad85 | 2009-08-25 13:59:41 -0700 | [diff] [blame] | 1237 | struct fcoe_interface *fcoe; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1238 | struct fc_frame_header *fh; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1239 | struct fcoe_percpu_s *fps; |
Vasu Dev | 519e513 | 2010-07-20 15:19:32 -0700 | [diff] [blame] | 1240 | struct ethhdr *eh; |
Vasu Dev | b2f0091 | 2009-08-25 13:58:53 -0700 | [diff] [blame] | 1241 | unsigned int cpu; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1242 | |
Chris Leech | 259ad85 | 2009-08-25 13:59:41 -0700 | [diff] [blame] | 1243 | fcoe = container_of(ptype, struct fcoe_interface, fcoe_packet_type); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1244 | lport = fcoe->ctlr.lp; |
| 1245 | if (unlikely(!lport)) { |
| 1246 | FCOE_NETDEV_DBG(netdev, "Cannot find hba structure"); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1247 | goto err2; |
| 1248 | } |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1249 | if (!lport->link_up) |
Joe Eykholt | 97c8389 | 2009-03-17 11:42:40 -0700 | [diff] [blame] | 1250 | goto err2; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1251 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1252 | FCOE_NETDEV_DBG(netdev, "skb_info: len:%d data_len:%d head:%p " |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 1253 | "data:%p tail:%p end:%p sum:%d dev:%s", |
| 1254 | skb->len, skb->data_len, skb->head, skb->data, |
| 1255 | skb_tail_pointer(skb), skb_end_pointer(skb), |
| 1256 | skb->csum, skb->dev ? skb->dev->name : "<NULL>"); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1257 | |
Vasu Dev | 519e513 | 2010-07-20 15:19:32 -0700 | [diff] [blame] | 1258 | eh = eth_hdr(skb); |
Vasu Dev | 519e513 | 2010-07-20 15:19:32 -0700 | [diff] [blame] | 1259 | |
| 1260 | if (is_fip_mode(&fcoe->ctlr) && |
| 1261 | compare_ether_addr(eh->h_source, fcoe->ctlr.dest_addr)) { |
| 1262 | FCOE_NETDEV_DBG(netdev, "wrong source mac address:%pM\n", |
| 1263 | eh->h_source); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1264 | goto err; |
| 1265 | } |
| 1266 | |
| 1267 | /* |
| 1268 | * Check for minimum frame length, and make sure required FCoE |
| 1269 | * and FC headers are pulled into the linear data area. |
| 1270 | */ |
| 1271 | if (unlikely((skb->len < FCOE_MIN_FRAME) || |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1272 | !pskb_may_pull(skb, FCOE_HEADER_LEN))) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1273 | goto err; |
| 1274 | |
| 1275 | skb_set_transport_header(skb, sizeof(struct fcoe_hdr)); |
| 1276 | fh = (struct fc_frame_header *) skb_transport_header(skb); |
| 1277 | |
Robert Love | 0ee31cb | 2010-10-08 17:12:46 -0700 | [diff] [blame] | 1278 | if (ntoh24(&eh->h_dest[3]) != ntoh24(fh->fh_d_id)) { |
| 1279 | FCOE_NETDEV_DBG(netdev, "FC frame d_id mismatch with MAC:%pM\n", |
| 1280 | eh->h_dest); |
| 1281 | goto err; |
| 1282 | } |
| 1283 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1284 | fr = fcoe_dev_from_skb(skb); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1285 | fr->fr_dev = lport; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1286 | fr->ptype = ptype; |
Robert Love | 5e5e92d | 2009-03-17 11:41:35 -0700 | [diff] [blame] | 1287 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1288 | /* |
Vasu Dev | b2f0091 | 2009-08-25 13:58:53 -0700 | [diff] [blame] | 1289 | * In case the incoming frame's exchange is originated from |
| 1290 | * the initiator, then received frame's exchange id is ANDed |
| 1291 | * with fc_cpu_mask bits to get the same cpu on which exchange |
| 1292 | * was originated, otherwise just use the current cpu. |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1293 | */ |
Vasu Dev | b2f0091 | 2009-08-25 13:58:53 -0700 | [diff] [blame] | 1294 | if (ntoh24(fh->fh_f_ctl) & FC_FC_EX_CTX) |
| 1295 | cpu = ntohs(fh->fh_ox_id) & fc_cpu_mask; |
| 1296 | else |
| 1297 | cpu = smp_processor_id(); |
Robert Love | 5e5e92d | 2009-03-17 11:41:35 -0700 | [diff] [blame] | 1298 | |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1299 | fps = &per_cpu(fcoe_percpu, cpu); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1300 | spin_lock_bh(&fps->fcoe_rx_list.lock); |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1301 | if (unlikely(!fps->thread)) { |
| 1302 | /* |
| 1303 | * The targeted CPU is not ready, let's target |
| 1304 | * the first CPU now. For non-SMP systems this |
| 1305 | * will check the same CPU twice. |
| 1306 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1307 | FCOE_NETDEV_DBG(netdev, "CPU is online, but no receive thread " |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 1308 | "ready for incoming skb- using first online " |
| 1309 | "CPU.\n"); |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1310 | |
| 1311 | spin_unlock_bh(&fps->fcoe_rx_list.lock); |
Rusty Russell | 6957177 | 2009-12-17 11:43:14 -0600 | [diff] [blame] | 1312 | cpu = cpumask_first(cpu_online_mask); |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 1313 | fps = &per_cpu(fcoe_percpu, cpu); |
| 1314 | spin_lock_bh(&fps->fcoe_rx_list.lock); |
| 1315 | if (!fps->thread) { |
| 1316 | spin_unlock_bh(&fps->fcoe_rx_list.lock); |
| 1317 | goto err; |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | /* |
| 1322 | * We now have a valid CPU that we're targeting for |
| 1323 | * this skb. We also have this receive thread locked, |
| 1324 | * so we're free to queue skbs into it's queue. |
| 1325 | */ |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1326 | |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1327 | /* If this is a SCSI-FCP frame, and this is already executing on the |
| 1328 | * correct CPU, and the queue for this CPU is empty, then go ahead |
| 1329 | * and process the frame directly in the softirq context. |
| 1330 | * This lets us process completions without context switching from the |
| 1331 | * NET_RX softirq, to our receive processing thread, and then back to |
| 1332 | * BLOCK softirq context. |
| 1333 | */ |
| 1334 | if (fh->fh_type == FC_TYPE_FCP && |
| 1335 | cpu == smp_processor_id() && |
| 1336 | skb_queue_empty(&fps->fcoe_rx_list)) { |
| 1337 | spin_unlock_bh(&fps->fcoe_rx_list.lock); |
| 1338 | fcoe_recv_frame(skb); |
| 1339 | } else { |
| 1340 | __skb_queue_tail(&fps->fcoe_rx_list, skb); |
| 1341 | if (fps->fcoe_rx_list.qlen == 1) |
| 1342 | wake_up_process(fps->thread); |
| 1343 | spin_unlock_bh(&fps->fcoe_rx_list.lock); |
| 1344 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1345 | |
| 1346 | return 0; |
| 1347 | err: |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1348 | per_cpu_ptr(lport->dev_stats, get_cpu())->ErrorFrames++; |
| 1349 | put_cpu(); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1350 | err2: |
| 1351 | kfree_skb(skb); |
| 1352 | return -1; |
| 1353 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1354 | |
| 1355 | /** |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 1356 | * fcoe_alloc_paged_crc_eof() - Allocate a page to be used for the trailer CRC |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1357 | * @skb: The packet to be transmitted |
| 1358 | * @tlen: The total length of the trailer |
| 1359 | * |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1360 | * Returns: 0 for success |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 1361 | */ |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 1362 | static int fcoe_alloc_paged_crc_eof(struct sk_buff *skb, int tlen) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1363 | { |
| 1364 | struct fcoe_percpu_s *fps; |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 1365 | int rc; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1366 | |
Robert Love | 5e5e92d | 2009-03-17 11:41:35 -0700 | [diff] [blame] | 1367 | fps = &get_cpu_var(fcoe_percpu); |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 1368 | rc = fcoe_get_paged_crc_eof(skb, tlen, fps); |
Robert Love | 5e5e92d | 2009-03-17 11:41:35 -0700 | [diff] [blame] | 1369 | put_cpu_var(fcoe_percpu); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1370 | |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 1371 | return rc; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1372 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1373 | |
| 1374 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1375 | * fcoe_xmit() - Transmit a FCoE frame |
| 1376 | * @lport: The local port that the frame is to be transmitted for |
| 1377 | * @fp: The frame to be transmitted |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1378 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1379 | * Return: 0 for success |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 1380 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1381 | int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1382 | { |
Vasu Dev | 4bb6b51 | 2009-05-06 10:52:34 -0700 | [diff] [blame] | 1383 | int wlen; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1384 | u32 crc; |
| 1385 | struct ethhdr *eh; |
| 1386 | struct fcoe_crc_eof *cp; |
| 1387 | struct sk_buff *skb; |
| 1388 | struct fcoe_dev_stats *stats; |
| 1389 | struct fc_frame_header *fh; |
| 1390 | unsigned int hlen; /* header length implies the version */ |
| 1391 | unsigned int tlen; /* trailer length */ |
| 1392 | unsigned int elen; /* eth header, may include vlan */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1393 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 1394 | struct fcoe_interface *fcoe = port->priv; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1395 | u8 sof, eof; |
| 1396 | struct fcoe_hdr *hp; |
| 1397 | |
| 1398 | WARN_ON((fr_len(fp) % sizeof(u32)) != 0); |
| 1399 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1400 | fh = fc_frame_header_get(fp); |
Joe Eykholt | 97c8389 | 2009-03-17 11:42:40 -0700 | [diff] [blame] | 1401 | skb = fp_skb(fp); |
| 1402 | wlen = skb->len / FCOE_WORD_TO_BYTE; |
| 1403 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1404 | if (!lport->link_up) { |
Dan Carpenter | 3caf02e | 2009-04-21 16:27:25 -0700 | [diff] [blame] | 1405 | kfree_skb(skb); |
Joe Eykholt | 97c8389 | 2009-03-17 11:42:40 -0700 | [diff] [blame] | 1406 | return 0; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1407 | } |
| 1408 | |
Joe Eykholt | 9860eeb | 2010-03-12 16:07:52 -0800 | [diff] [blame] | 1409 | if (unlikely(fh->fh_type == FC_TYPE_ELS) && |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1410 | fcoe_ctlr_els_send(&fcoe->ctlr, lport, skb)) |
Joe Eykholt | 97c8389 | 2009-03-17 11:42:40 -0700 | [diff] [blame] | 1411 | return 0; |
| 1412 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1413 | sof = fr_sof(fp); |
| 1414 | eof = fr_eof(fp); |
| 1415 | |
Vasu Dev | 4e57e1c | 2009-05-06 10:52:46 -0700 | [diff] [blame] | 1416 | elen = sizeof(struct ethhdr); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1417 | hlen = sizeof(struct fcoe_hdr); |
| 1418 | tlen = sizeof(struct fcoe_crc_eof); |
| 1419 | wlen = (skb->len - tlen + sizeof(crc)) / FCOE_WORD_TO_BYTE; |
| 1420 | |
| 1421 | /* crc offload */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1422 | if (likely(lport->crc_offload)) { |
Yi Zou | 39ca9a0 | 2009-02-27 14:07:15 -0800 | [diff] [blame] | 1423 | skb->ip_summed = CHECKSUM_PARTIAL; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1424 | skb->csum_start = skb_headroom(skb); |
| 1425 | skb->csum_offset = skb->len; |
| 1426 | crc = 0; |
| 1427 | } else { |
| 1428 | skb->ip_summed = CHECKSUM_NONE; |
| 1429 | crc = fcoe_fc_crc(fp); |
| 1430 | } |
| 1431 | |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 1432 | /* copy port crc and eof to the skb buff */ |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1433 | if (skb_is_nonlinear(skb)) { |
| 1434 | skb_frag_t *frag; |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 1435 | if (fcoe_alloc_paged_crc_eof(skb, tlen)) { |
Roel Kluin | e904158 | 2009-02-27 10:56:22 -0800 | [diff] [blame] | 1436 | kfree_skb(skb); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1437 | return -ENOMEM; |
| 1438 | } |
| 1439 | frag = &skb_shinfo(skb)->frags[skb_shinfo(skb)->nr_frags - 1]; |
| 1440 | cp = kmap_atomic(frag->page, KM_SKB_DATA_SOFTIRQ) |
| 1441 | + frag->page_offset; |
| 1442 | } else { |
| 1443 | cp = (struct fcoe_crc_eof *)skb_put(skb, tlen); |
| 1444 | } |
| 1445 | |
| 1446 | memset(cp, 0, sizeof(*cp)); |
| 1447 | cp->fcoe_eof = eof; |
| 1448 | cp->fcoe_crc32 = cpu_to_le32(~crc); |
| 1449 | |
| 1450 | if (skb_is_nonlinear(skb)) { |
| 1451 | kunmap_atomic(cp, KM_SKB_DATA_SOFTIRQ); |
| 1452 | cp = NULL; |
| 1453 | } |
| 1454 | |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 1455 | /* adjust skb network/transport offsets to match mac/fcoe/port */ |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1456 | skb_push(skb, elen + hlen); |
| 1457 | skb_reset_mac_header(skb); |
| 1458 | skb_reset_network_header(skb); |
| 1459 | skb->mac_len = elen; |
Yi Zou | 211c738 | 2009-02-27 14:06:37 -0800 | [diff] [blame] | 1460 | skb->protocol = htons(ETH_P_FCOE); |
Chris Leech | 3fe9a0b | 2009-08-25 13:59:46 -0700 | [diff] [blame] | 1461 | skb->dev = fcoe->netdev; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1462 | |
| 1463 | /* fill up mac and fcoe headers */ |
| 1464 | eh = eth_hdr(skb); |
| 1465 | eh->h_proto = htons(ETH_P_FCOE); |
Joe Eykholt | cd229e4 | 2010-07-20 15:20:40 -0700 | [diff] [blame] | 1466 | memcpy(eh->h_dest, fcoe->ctlr.dest_addr, ETH_ALEN); |
Chris Leech | 3fe9a0b | 2009-08-25 13:59:46 -0700 | [diff] [blame] | 1467 | if (fcoe->ctlr.map_dest) |
Joe Eykholt | cd229e4 | 2010-07-20 15:20:40 -0700 | [diff] [blame] | 1468 | memcpy(eh->h_dest + 3, fh->fh_d_id, 3); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1469 | |
Chris Leech | 3fe9a0b | 2009-08-25 13:59:46 -0700 | [diff] [blame] | 1470 | if (unlikely(fcoe->ctlr.flogi_oxid != FC_XID_UNKNOWN)) |
| 1471 | memcpy(eh->h_source, fcoe->ctlr.ctl_src_addr, ETH_ALEN); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1472 | else |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 1473 | memcpy(eh->h_source, port->data_src_addr, ETH_ALEN); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1474 | |
| 1475 | hp = (struct fcoe_hdr *)(eh + 1); |
| 1476 | memset(hp, 0, sizeof(*hp)); |
| 1477 | if (FC_FCOE_VER) |
| 1478 | FC_FCOE_ENCAPS_VER(hp, FC_FCOE_VER); |
| 1479 | hp->fcoe_sof = sof; |
| 1480 | |
Yi Zou | 39ca9a0 | 2009-02-27 14:07:15 -0800 | [diff] [blame] | 1481 | /* fcoe lso, mss is in max_payload which is non-zero for FCP data */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1482 | if (lport->seq_offload && fr_max_payload(fp)) { |
Yi Zou | 39ca9a0 | 2009-02-27 14:07:15 -0800 | [diff] [blame] | 1483 | skb_shinfo(skb)->gso_type = SKB_GSO_FCOE; |
| 1484 | skb_shinfo(skb)->gso_size = fr_max_payload(fp); |
| 1485 | } else { |
| 1486 | skb_shinfo(skb)->gso_type = 0; |
| 1487 | skb_shinfo(skb)->gso_size = 0; |
| 1488 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1489 | /* update tx stats: regardless if LLD fails */ |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1490 | stats = per_cpu_ptr(lport->dev_stats, get_cpu()); |
Robert Love | 582b45b | 2009-03-31 15:51:50 -0700 | [diff] [blame] | 1491 | stats->TxFrames++; |
| 1492 | stats->TxWords += wlen; |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1493 | put_cpu(); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1494 | |
| 1495 | /* send down to lld */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1496 | fr_dev(fp) = lport; |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 1497 | if (port->fcoe_pending_queue.qlen) |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1498 | fcoe_check_wait_queue(lport, skb); |
Vasu Dev | 4bb6b51 | 2009-05-06 10:52:34 -0700 | [diff] [blame] | 1499 | else if (fcoe_start_io(skb)) |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1500 | fcoe_check_wait_queue(lport, skb); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1501 | |
| 1502 | return 0; |
| 1503 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1504 | |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 1505 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1506 | * fcoe_percpu_flush_done() - Indicate per-CPU queue flush completion |
| 1507 | * @skb: The completed skb (argument required by destructor) |
Joe Eykholt | e7a5199 | 2009-08-25 14:04:08 -0700 | [diff] [blame] | 1508 | */ |
| 1509 | static void fcoe_percpu_flush_done(struct sk_buff *skb) |
| 1510 | { |
| 1511 | complete(&fcoe_flush_completion); |
| 1512 | } |
| 1513 | |
| 1514 | /** |
Vasu Dev | 52ee832 | 2011-01-28 16:03:52 -0800 | [diff] [blame] | 1515 | * fcoe_filter_frames() - filter out bad fcoe frames, i.e. bad CRC |
| 1516 | * @lport: The local port the frame was received on |
| 1517 | * @fp: The received frame |
| 1518 | * |
| 1519 | * Return: 0 on passing filtering checks |
| 1520 | */ |
| 1521 | static inline int fcoe_filter_frames(struct fc_lport *lport, |
| 1522 | struct fc_frame *fp) |
| 1523 | { |
| 1524 | struct fcoe_interface *fcoe; |
| 1525 | struct fc_frame_header *fh; |
| 1526 | struct sk_buff *skb = (struct sk_buff *)fp; |
| 1527 | struct fcoe_dev_stats *stats; |
| 1528 | |
| 1529 | /* |
| 1530 | * We only check CRC if no offload is available and if it is |
| 1531 | * it's solicited data, in which case, the FCP layer would |
| 1532 | * check it during the copy. |
| 1533 | */ |
| 1534 | if (lport->crc_offload && skb->ip_summed == CHECKSUM_UNNECESSARY) |
| 1535 | fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED; |
| 1536 | else |
| 1537 | fr_flags(fp) |= FCPHF_CRC_UNCHECKED; |
| 1538 | |
| 1539 | fh = (struct fc_frame_header *) skb_transport_header(skb); |
| 1540 | fh = fc_frame_header_get(fp); |
| 1541 | if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA && fh->fh_type == FC_TYPE_FCP) |
| 1542 | return 0; |
| 1543 | |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 1544 | fcoe = ((struct fcoe_port *)lport_priv(lport))->priv; |
Vasu Dev | 52ee832 | 2011-01-28 16:03:52 -0800 | [diff] [blame] | 1545 | if (is_fip_mode(&fcoe->ctlr) && fc_frame_payload_op(fp) == ELS_LOGO && |
| 1546 | ntoh24(fh->fh_s_id) == FC_FID_FLOGI) { |
| 1547 | FCOE_DBG("fcoe: dropping FCoE lport LOGO in fip mode\n"); |
| 1548 | return -EINVAL; |
| 1549 | } |
| 1550 | |
| 1551 | if (!fr_flags(fp) & FCPHF_CRC_UNCHECKED || |
| 1552 | le32_to_cpu(fr_crc(fp)) == ~crc32(~0, skb->data, skb->len)) { |
| 1553 | fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED; |
| 1554 | return 0; |
| 1555 | } |
| 1556 | |
| 1557 | stats = per_cpu_ptr(lport->dev_stats, get_cpu()); |
| 1558 | stats->InvalidCRCCount++; |
| 1559 | if (stats->InvalidCRCCount < 5) |
| 1560 | printk(KERN_WARNING "fcoe: dropping frame with CRC error\n"); |
| 1561 | return -EINVAL; |
| 1562 | } |
| 1563 | |
| 1564 | /** |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1565 | * fcoe_recv_frame() - process a single received frame |
| 1566 | * @skb: frame to process |
| 1567 | */ |
| 1568 | static void fcoe_recv_frame(struct sk_buff *skb) |
| 1569 | { |
| 1570 | u32 fr_len; |
| 1571 | struct fc_lport *lport; |
| 1572 | struct fcoe_rcv_info *fr; |
| 1573 | struct fcoe_dev_stats *stats; |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1574 | struct fcoe_crc_eof crc_eof; |
| 1575 | struct fc_frame *fp; |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1576 | struct fcoe_port *port; |
| 1577 | struct fcoe_hdr *hp; |
| 1578 | |
| 1579 | fr = fcoe_dev_from_skb(skb); |
| 1580 | lport = fr->fr_dev; |
| 1581 | if (unlikely(!lport)) { |
| 1582 | if (skb->destructor != fcoe_percpu_flush_done) |
| 1583 | FCOE_NETDEV_DBG(skb->dev, "NULL lport in skb"); |
| 1584 | kfree_skb(skb); |
| 1585 | return; |
| 1586 | } |
| 1587 | |
| 1588 | FCOE_NETDEV_DBG(skb->dev, "skb_info: len:%d data_len:%d " |
| 1589 | "head:%p data:%p tail:%p end:%p sum:%d dev:%s", |
| 1590 | skb->len, skb->data_len, |
| 1591 | skb->head, skb->data, skb_tail_pointer(skb), |
| 1592 | skb_end_pointer(skb), skb->csum, |
| 1593 | skb->dev ? skb->dev->name : "<NULL>"); |
| 1594 | |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1595 | port = lport_priv(lport); |
| 1596 | if (skb_is_nonlinear(skb)) |
| 1597 | skb_linearize(skb); /* not ideal */ |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1598 | |
| 1599 | /* |
| 1600 | * Frame length checks and setting up the header pointers |
| 1601 | * was done in fcoe_rcv already. |
| 1602 | */ |
| 1603 | hp = (struct fcoe_hdr *) skb_network_header(skb); |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1604 | |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1605 | stats = per_cpu_ptr(lport->dev_stats, get_cpu()); |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1606 | if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) { |
| 1607 | if (stats->ErrorFrames < 5) |
| 1608 | printk(KERN_WARNING "fcoe: FCoE version " |
| 1609 | "mismatch: The frame has " |
| 1610 | "version %x, but the " |
| 1611 | "initiator supports version " |
| 1612 | "%x\n", FC_FCOE_DECAPS_VER(hp), |
| 1613 | FC_FCOE_VER); |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1614 | goto drop; |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1615 | } |
| 1616 | |
| 1617 | skb_pull(skb, sizeof(struct fcoe_hdr)); |
| 1618 | fr_len = skb->len - sizeof(struct fcoe_crc_eof); |
| 1619 | |
| 1620 | stats->RxFrames++; |
| 1621 | stats->RxWords += fr_len / FCOE_WORD_TO_BYTE; |
| 1622 | |
| 1623 | fp = (struct fc_frame *)skb; |
| 1624 | fc_frame_init(fp); |
| 1625 | fr_dev(fp) = lport; |
| 1626 | fr_sof(fp) = hp->fcoe_sof; |
| 1627 | |
| 1628 | /* Copy out the CRC and EOF trailer for access */ |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1629 | if (skb_copy_bits(skb, fr_len, &crc_eof, sizeof(crc_eof))) |
| 1630 | goto drop; |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1631 | fr_eof(fp) = crc_eof.fcoe_eof; |
| 1632 | fr_crc(fp) = crc_eof.fcoe_crc32; |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1633 | if (pskb_trim(skb, fr_len)) |
| 1634 | goto drop; |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1635 | |
Vasu Dev | 52ee832 | 2011-01-28 16:03:52 -0800 | [diff] [blame] | 1636 | if (!fcoe_filter_frames(lport, fp)) { |
| 1637 | put_cpu(); |
| 1638 | fc_exch_recv(lport, fp); |
| 1639 | return; |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1640 | } |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1641 | drop: |
| 1642 | stats->ErrorFrames++; |
| 1643 | put_cpu(); |
| 1644 | kfree_skb(skb); |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1645 | } |
| 1646 | |
| 1647 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1648 | * fcoe_percpu_receive_thread() - The per-CPU packet receive thread |
| 1649 | * @arg: The per-CPU context |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1650 | * |
| 1651 | * Return: 0 for success |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1652 | */ |
| 1653 | int fcoe_percpu_receive_thread(void *arg) |
| 1654 | { |
| 1655 | struct fcoe_percpu_s *p = arg; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1656 | struct sk_buff *skb; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1657 | |
Robert Love | 4469c19 | 2009-02-27 10:56:38 -0800 | [diff] [blame] | 1658 | set_user_nice(current, -20); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1659 | |
| 1660 | while (!kthread_should_stop()) { |
| 1661 | |
| 1662 | spin_lock_bh(&p->fcoe_rx_list.lock); |
| 1663 | while ((skb = __skb_dequeue(&p->fcoe_rx_list)) == NULL) { |
| 1664 | set_current_state(TASK_INTERRUPTIBLE); |
| 1665 | spin_unlock_bh(&p->fcoe_rx_list.lock); |
| 1666 | schedule(); |
| 1667 | set_current_state(TASK_RUNNING); |
| 1668 | if (kthread_should_stop()) |
| 1669 | return 0; |
| 1670 | spin_lock_bh(&p->fcoe_rx_list.lock); |
| 1671 | } |
| 1672 | spin_unlock_bh(&p->fcoe_rx_list.lock); |
Chris Leech | 859b7b6 | 2009-11-20 14:54:47 -0800 | [diff] [blame] | 1673 | fcoe_recv_frame(skb); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1674 | } |
| 1675 | return 0; |
| 1676 | } |
| 1677 | |
| 1678 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1679 | * fcoe_dev_setup() - Setup the link change notification interface |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 1680 | */ |
Randy Dunlap | b0d428a | 2009-04-27 21:49:31 -0700 | [diff] [blame] | 1681 | static void fcoe_dev_setup(void) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1682 | { |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1683 | register_netdevice_notifier(&fcoe_notifier); |
| 1684 | } |
| 1685 | |
| 1686 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1687 | * fcoe_dev_cleanup() - Cleanup the link change notification interface |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 1688 | */ |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1689 | static void fcoe_dev_cleanup(void) |
| 1690 | { |
| 1691 | unregister_netdevice_notifier(&fcoe_notifier); |
| 1692 | } |
| 1693 | |
| 1694 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1695 | * fcoe_device_notification() - Handler for net device events |
| 1696 | * @notifier: The context of the notification |
| 1697 | * @event: The type of event |
| 1698 | * @ptr: The net device that the event was on |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1699 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1700 | * This function is called by the Ethernet driver in case of link change event. |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1701 | * |
| 1702 | * Returns: 0 for success |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 1703 | */ |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1704 | static int fcoe_device_notification(struct notifier_block *notifier, |
| 1705 | ulong event, void *ptr) |
| 1706 | { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1707 | struct fc_lport *lport = NULL; |
Vasu Dev | 1d1b88d | 2009-07-29 17:05:45 -0700 | [diff] [blame] | 1708 | struct net_device *netdev = ptr; |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 1709 | struct fcoe_interface *fcoe; |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 1710 | struct fcoe_port *port; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1711 | struct fcoe_dev_stats *stats; |
Joe Eykholt | 97c8389 | 2009-03-17 11:42:40 -0700 | [diff] [blame] | 1712 | u32 link_possible = 1; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1713 | u32 mfs; |
| 1714 | int rc = NOTIFY_OK; |
| 1715 | |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 1716 | list_for_each_entry(fcoe, &fcoe_hostlist, list) { |
Chris Leech | 2502498 | 2009-08-25 13:59:35 -0700 | [diff] [blame] | 1717 | if (fcoe->netdev == netdev) { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1718 | lport = fcoe->ctlr.lp; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1719 | break; |
| 1720 | } |
| 1721 | } |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1722 | if (!lport) { |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1723 | rc = NOTIFY_DONE; |
| 1724 | goto out; |
| 1725 | } |
| 1726 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1727 | switch (event) { |
| 1728 | case NETDEV_DOWN: |
| 1729 | case NETDEV_GOING_DOWN: |
Joe Eykholt | 97c8389 | 2009-03-17 11:42:40 -0700 | [diff] [blame] | 1730 | link_possible = 0; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1731 | break; |
| 1732 | case NETDEV_UP: |
| 1733 | case NETDEV_CHANGE: |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1734 | break; |
| 1735 | case NETDEV_CHANGEMTU: |
Yi Zou | 7221d7e | 2009-10-21 16:27:52 -0700 | [diff] [blame] | 1736 | if (netdev->features & NETIF_F_FCOE_MTU) |
| 1737 | break; |
Vasu Dev | 1d1b88d | 2009-07-29 17:05:45 -0700 | [diff] [blame] | 1738 | mfs = netdev->mtu - (sizeof(struct fcoe_hdr) + |
| 1739 | sizeof(struct fcoe_crc_eof)); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1740 | if (mfs >= FC_MIN_MAX_FRAME) |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1741 | fc_set_mfs(lport, mfs); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1742 | break; |
| 1743 | case NETDEV_REGISTER: |
| 1744 | break; |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 1745 | case NETDEV_UNREGISTER: |
| 1746 | list_del(&fcoe->list); |
| 1747 | port = lport_priv(fcoe->ctlr.lp); |
| 1748 | fcoe_interface_cleanup(fcoe); |
Tejun Heo | 2ca32b4 | 2011-01-28 16:05:32 -0800 | [diff] [blame] | 1749 | queue_work(fcoe_wq, &port->destroy_work); |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 1750 | goto out; |
| 1751 | break; |
Yi Zou | 54a5b21 | 2010-07-20 15:21:17 -0700 | [diff] [blame] | 1752 | case NETDEV_FEAT_CHANGE: |
| 1753 | fcoe_netdev_features_change(lport, netdev); |
| 1754 | break; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1755 | default: |
Vasu Dev | 1d1b88d | 2009-07-29 17:05:45 -0700 | [diff] [blame] | 1756 | FCOE_NETDEV_DBG(netdev, "Unknown event %ld " |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 1757 | "from netdev netlink\n", event); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1758 | } |
Robert Love | 5e4f8fe | 2010-05-07 15:18:35 -0700 | [diff] [blame] | 1759 | |
| 1760 | fcoe_link_speed_update(lport); |
| 1761 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1762 | if (link_possible && !fcoe_link_ok(lport)) |
Chris Leech | 3fe9a0b | 2009-08-25 13:59:46 -0700 | [diff] [blame] | 1763 | fcoe_ctlr_link_up(&fcoe->ctlr); |
| 1764 | else if (fcoe_ctlr_link_down(&fcoe->ctlr)) { |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1765 | stats = per_cpu_ptr(lport->dev_stats, get_cpu()); |
Joe Eykholt | 97c8389 | 2009-03-17 11:42:40 -0700 | [diff] [blame] | 1766 | stats->LinkFailureCount++; |
Joe Eykholt | f018b73 | 2010-03-12 16:08:55 -0800 | [diff] [blame] | 1767 | put_cpu(); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1768 | fcoe_clean_pending_queue(lport); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1769 | } |
| 1770 | out: |
| 1771 | return rc; |
| 1772 | } |
| 1773 | |
| 1774 | /** |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1775 | * fcoe_disable() - Disables a FCoE interface |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1776 | * @netdev : The net_device object the Ethernet interface to create on |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1777 | * |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1778 | * Called from fcoe transport. |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1779 | * |
| 1780 | * Returns: 0 for success |
| 1781 | */ |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1782 | static int fcoe_disable(struct net_device *netdev) |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1783 | { |
| 1784 | struct fcoe_interface *fcoe; |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1785 | int rc = 0; |
| 1786 | |
| 1787 | mutex_lock(&fcoe_config_mutex); |
| 1788 | #ifdef CONFIG_FCOE_MODULE |
| 1789 | /* |
| 1790 | * Make sure the module has been initialized, and is not about to be |
| 1791 | * removed. Module paramter sysfs files are writable before the |
| 1792 | * module_init function is called and after module_exit. |
| 1793 | */ |
| 1794 | if (THIS_MODULE->state != MODULE_STATE_LIVE) { |
| 1795 | rc = -ENODEV; |
| 1796 | goto out_nodev; |
| 1797 | } |
| 1798 | #endif |
| 1799 | |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1800 | if (!rtnl_trylock()) { |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1801 | mutex_unlock(&fcoe_config_mutex); |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1802 | return -ERESTARTSYS; |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1803 | } |
| 1804 | |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1805 | fcoe = fcoe_hostlist_lookup_port(netdev); |
| 1806 | rtnl_unlock(); |
| 1807 | |
Chris Leech | 9ee50e4 | 2010-04-09 14:22:23 -0700 | [diff] [blame] | 1808 | if (fcoe) { |
Chris Leech | 9ee50e4 | 2010-04-09 14:22:23 -0700 | [diff] [blame] | 1809 | fcoe_ctlr_link_down(&fcoe->ctlr); |
Vasu Dev | 9d4cbc0 | 2010-07-20 15:19:26 -0700 | [diff] [blame] | 1810 | fcoe_clean_pending_queue(fcoe->ctlr.lp); |
Chris Leech | 9ee50e4 | 2010-04-09 14:22:23 -0700 | [diff] [blame] | 1811 | } else |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1812 | rc = -ENODEV; |
| 1813 | |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1814 | out_nodev: |
| 1815 | mutex_unlock(&fcoe_config_mutex); |
| 1816 | return rc; |
| 1817 | } |
| 1818 | |
| 1819 | /** |
| 1820 | * fcoe_enable() - Enables a FCoE interface |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1821 | * @netdev : The net_device object the Ethernet interface to create on |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1822 | * |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1823 | * Called from fcoe transport. |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1824 | * |
| 1825 | * Returns: 0 for success |
| 1826 | */ |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1827 | static int fcoe_enable(struct net_device *netdev) |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1828 | { |
| 1829 | struct fcoe_interface *fcoe; |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1830 | int rc = 0; |
| 1831 | |
| 1832 | mutex_lock(&fcoe_config_mutex); |
| 1833 | #ifdef CONFIG_FCOE_MODULE |
| 1834 | /* |
| 1835 | * Make sure the module has been initialized, and is not about to be |
| 1836 | * removed. Module paramter sysfs files are writable before the |
| 1837 | * module_init function is called and after module_exit. |
| 1838 | */ |
| 1839 | if (THIS_MODULE->state != MODULE_STATE_LIVE) { |
| 1840 | rc = -ENODEV; |
| 1841 | goto out_nodev; |
| 1842 | } |
| 1843 | #endif |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1844 | if (!rtnl_trylock()) { |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1845 | mutex_unlock(&fcoe_config_mutex); |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1846 | return -ERESTARTSYS; |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1847 | } |
| 1848 | |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1849 | fcoe = fcoe_hostlist_lookup_port(netdev); |
| 1850 | rtnl_unlock(); |
| 1851 | |
Vasu Dev | 9d4cbc0 | 2010-07-20 15:19:26 -0700 | [diff] [blame] | 1852 | if (!fcoe) |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1853 | rc = -ENODEV; |
Vasu Dev | 9d4cbc0 | 2010-07-20 15:19:26 -0700 | [diff] [blame] | 1854 | else if (!fcoe_link_ok(fcoe->ctlr.lp)) |
| 1855 | fcoe_ctlr_link_up(&fcoe->ctlr); |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1856 | |
Vasu Dev | 55a66d3 | 2009-12-10 09:59:31 -0800 | [diff] [blame] | 1857 | out_nodev: |
| 1858 | mutex_unlock(&fcoe_config_mutex); |
| 1859 | return rc; |
| 1860 | } |
| 1861 | |
| 1862 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1863 | * fcoe_destroy() - Destroy a FCoE interface |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1864 | * @netdev : The net_device object the Ethernet interface to create on |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1865 | * |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1866 | * Called from fcoe transport |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1867 | * |
| 1868 | * Returns: 0 for success |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 1869 | */ |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1870 | static int fcoe_destroy(struct net_device *netdev) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1871 | { |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 1872 | struct fcoe_interface *fcoe; |
Mike Christie | 8eca355f | 2009-10-21 16:27:44 -0700 | [diff] [blame] | 1873 | int rc = 0; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1874 | |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 1875 | mutex_lock(&fcoe_config_mutex); |
| 1876 | #ifdef CONFIG_FCOE_MODULE |
| 1877 | /* |
| 1878 | * Make sure the module has been initialized, and is not about to be |
| 1879 | * removed. Module paramter sysfs files are writable before the |
| 1880 | * module_init function is called and after module_exit. |
| 1881 | */ |
| 1882 | if (THIS_MODULE->state != MODULE_STATE_LIVE) { |
| 1883 | rc = -ENODEV; |
| 1884 | goto out_nodev; |
| 1885 | } |
| 1886 | #endif |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1887 | if (!rtnl_trylock()) { |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1888 | mutex_unlock(&fcoe_config_mutex); |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1889 | return -ERESTARTSYS; |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1890 | } |
| 1891 | |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 1892 | fcoe = fcoe_hostlist_lookup_port(netdev); |
| 1893 | if (!fcoe) { |
Chris Leech | 090eb6c | 2009-08-25 14:00:28 -0700 | [diff] [blame] | 1894 | rtnl_unlock(); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1895 | rc = -ENODEV; |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1896 | goto out_nodev; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1897 | } |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 1898 | fcoe_interface_cleanup(fcoe); |
Yi Zou | 54a5b21 | 2010-07-20 15:21:17 -0700 | [diff] [blame] | 1899 | list_del(&fcoe->list); |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1900 | /* RTNL mutex is dropped by fcoe_if_destroy */ |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 1901 | fcoe_if_destroy(fcoe->ctlr.lp); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1902 | out_nodev: |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 1903 | mutex_unlock(&fcoe_config_mutex); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1904 | return rc; |
| 1905 | } |
| 1906 | |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1907 | /** |
| 1908 | * fcoe_destroy_work() - Destroy a FCoE port in a deferred work context |
| 1909 | * @work: Handle to the FCoE port to be destroyed |
| 1910 | */ |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 1911 | static void fcoe_destroy_work(struct work_struct *work) |
| 1912 | { |
| 1913 | struct fcoe_port *port; |
| 1914 | |
| 1915 | port = container_of(work, struct fcoe_port, destroy_work); |
| 1916 | mutex_lock(&fcoe_config_mutex); |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1917 | rtnl_lock(); |
| 1918 | /* RTNL mutex is dropped by fcoe_if_destroy */ |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 1919 | fcoe_if_destroy(port->lport); |
| 1920 | mutex_unlock(&fcoe_config_mutex); |
| 1921 | } |
| 1922 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1923 | /** |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1924 | * fcoe_match() - Check if the FCoE is supported on the given netdevice |
| 1925 | * @netdev : The net_device object the Ethernet interface to create on |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 1926 | * |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1927 | * Called from fcoe transport. |
| 1928 | * |
| 1929 | * Returns: always returns true as this is the default FCoE transport, |
| 1930 | * i.e., support all netdevs. |
| 1931 | */ |
| 1932 | static bool fcoe_match(struct net_device *netdev) |
| 1933 | { |
| 1934 | return true; |
| 1935 | } |
| 1936 | |
| 1937 | /** |
| 1938 | * fcoe_create() - Create a fcoe interface |
| 1939 | * @netdev : The net_device object the Ethernet interface to create on |
| 1940 | * @fip_mode: The FIP mode for this creation |
| 1941 | * |
| 1942 | * Called from fcoe transport |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1943 | * |
| 1944 | * Returns: 0 for success |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 1945 | */ |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1946 | static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1947 | { |
| 1948 | int rc; |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 1949 | struct fcoe_interface *fcoe; |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 1950 | struct fc_lport *lport; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1951 | |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 1952 | mutex_lock(&fcoe_config_mutex); |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1953 | |
| 1954 | if (!rtnl_trylock()) { |
| 1955 | mutex_unlock(&fcoe_config_mutex); |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1956 | return -ERESTARTSYS; |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 1957 | } |
| 1958 | |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 1959 | #ifdef CONFIG_FCOE_MODULE |
| 1960 | /* |
| 1961 | * Make sure the module has been initialized, and is not about to be |
| 1962 | * removed. Module paramter sysfs files are writable before the |
| 1963 | * module_init function is called and after module_exit. |
| 1964 | */ |
| 1965 | if (THIS_MODULE->state != MODULE_STATE_LIVE) { |
| 1966 | rc = -ENODEV; |
Robert Love | 7287fb9 | 2011-01-28 16:03:47 -0800 | [diff] [blame] | 1967 | goto out_nodev; |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 1968 | } |
| 1969 | #endif |
| 1970 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1971 | /* look for existing lport */ |
| 1972 | if (fcoe_hostlist_lookup(netdev)) { |
| 1973 | rc = -EEXIST; |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1974 | goto out_nodev; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1975 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1976 | |
Joe Eykholt | 1dd454d | 2010-07-20 15:20:46 -0700 | [diff] [blame] | 1977 | fcoe = fcoe_interface_create(netdev, fip_mode); |
Robert Love | 7287fb9 | 2011-01-28 16:03:47 -0800 | [diff] [blame] | 1978 | if (IS_ERR(fcoe)) { |
| 1979 | rc = PTR_ERR(fcoe); |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 1980 | goto out_nodev; |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 1981 | } |
| 1982 | |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 1983 | lport = fcoe_if_create(fcoe, &netdev->dev, 0); |
Chris Leech | af7f85d | 2009-08-25 13:59:24 -0700 | [diff] [blame] | 1984 | if (IS_ERR(lport)) { |
Robert Love | d5488eb | 2009-06-10 15:30:59 -0700 | [diff] [blame] | 1985 | printk(KERN_ERR "fcoe: Failed to create interface (%s)\n", |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1986 | netdev->name); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1987 | rc = -EIO; |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 1988 | fcoe_interface_cleanup(fcoe); |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 1989 | goto out_free; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 1990 | } |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 1991 | |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 1992 | /* Make this the "master" N_Port */ |
| 1993 | fcoe->ctlr.lp = lport; |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 1994 | |
Chris Leech | c863df3 | 2009-08-25 14:00:18 -0700 | [diff] [blame] | 1995 | /* add to lports list */ |
| 1996 | fcoe_hostlist_add(lport); |
| 1997 | |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 1998 | /* start FIP Discovery and FLOGI */ |
| 1999 | lport->boot_time = jiffies; |
| 2000 | fc_fabric_login(lport); |
| 2001 | if (!fcoe_link_ok(lport)) |
| 2002 | fcoe_ctlr_link_up(&fcoe->ctlr); |
| 2003 | |
Chris Leech | 54b649f | 2009-08-25 14:00:07 -0700 | [diff] [blame] | 2004 | /* |
| 2005 | * Release from init in fcoe_interface_create(), on success lport |
| 2006 | * should be holding a reference taken in fcoe_if_create(). |
| 2007 | */ |
Chris Leech | 030f4e0 | 2009-08-25 14:00:02 -0700 | [diff] [blame] | 2008 | fcoe_interface_put(fcoe); |
Rob Love | 6409ea65 | 2010-01-21 10:16:05 -0800 | [diff] [blame] | 2009 | rtnl_unlock(); |
| 2010 | mutex_unlock(&fcoe_config_mutex); |
| 2011 | |
| 2012 | return 0; |
| 2013 | out_free: |
| 2014 | fcoe_interface_put(fcoe); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2015 | out_nodev: |
Vasu Dev | 34ce27b | 2010-05-07 15:18:46 -0700 | [diff] [blame] | 2016 | rtnl_unlock(); |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 2017 | mutex_unlock(&fcoe_config_mutex); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2018 | return rc; |
| 2019 | } |
| 2020 | |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 2021 | /** |
Robert Love | 5e4f8fe | 2010-05-07 15:18:35 -0700 | [diff] [blame] | 2022 | * fcoe_link_speed_update() - Update the supported and actual link speeds |
| 2023 | * @lport: The local port to update speeds for |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2024 | * |
Robert Love | 5e4f8fe | 2010-05-07 15:18:35 -0700 | [diff] [blame] | 2025 | * Returns: 0 if the ethtool query was successful |
| 2026 | * -1 if the ethtool query failed |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2027 | */ |
Robert Love | 5e4f8fe | 2010-05-07 15:18:35 -0700 | [diff] [blame] | 2028 | int fcoe_link_speed_update(struct fc_lport *lport) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2029 | { |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 2030 | struct net_device *netdev = fcoe_netdev(lport); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2031 | struct ethtool_cmd ecmd = { ETHTOOL_GSET }; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2032 | |
Robert Love | 5e4f8fe | 2010-05-07 15:18:35 -0700 | [diff] [blame] | 2033 | if (!dev_ethtool_get_settings(netdev, &ecmd)) { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2034 | lport->link_supported_speeds &= |
Yi Zou | 2f718d6 | 2009-07-29 17:04:01 -0700 | [diff] [blame] | 2035 | ~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT); |
| 2036 | if (ecmd.supported & (SUPPORTED_1000baseT_Half | |
| 2037 | SUPPORTED_1000baseT_Full)) |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2038 | lport->link_supported_speeds |= FC_PORTSPEED_1GBIT; |
Yi Zou | 2f718d6 | 2009-07-29 17:04:01 -0700 | [diff] [blame] | 2039 | if (ecmd.supported & SUPPORTED_10000baseT_Full) |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2040 | lport->link_supported_speeds |= |
Yi Zou | 2f718d6 | 2009-07-29 17:04:01 -0700 | [diff] [blame] | 2041 | FC_PORTSPEED_10GBIT; |
| 2042 | if (ecmd.speed == SPEED_1000) |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2043 | lport->link_speed = FC_PORTSPEED_1GBIT; |
Yi Zou | 2f718d6 | 2009-07-29 17:04:01 -0700 | [diff] [blame] | 2044 | if (ecmd.speed == SPEED_10000) |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2045 | lport->link_speed = FC_PORTSPEED_10GBIT; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2046 | |
Yi Zou | 2f718d6 | 2009-07-29 17:04:01 -0700 | [diff] [blame] | 2047 | return 0; |
| 2048 | } |
| 2049 | return -1; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2050 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2051 | |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 2052 | /** |
Robert Love | 5e4f8fe | 2010-05-07 15:18:35 -0700 | [diff] [blame] | 2053 | * fcoe_link_ok() - Check if the link is OK for a local port |
| 2054 | * @lport: The local port to check link on |
| 2055 | * |
| 2056 | * Returns: 0 if link is UP and OK, -1 if not |
| 2057 | * |
| 2058 | */ |
| 2059 | int fcoe_link_ok(struct fc_lport *lport) |
| 2060 | { |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 2061 | struct net_device *netdev = fcoe_netdev(lport); |
Robert Love | 5e4f8fe | 2010-05-07 15:18:35 -0700 | [diff] [blame] | 2062 | |
| 2063 | if (netif_oper_up(netdev)) |
| 2064 | return 0; |
| 2065 | return -1; |
| 2066 | } |
| 2067 | |
| 2068 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2069 | * fcoe_percpu_clean() - Clear all pending skbs for an local port |
| 2070 | * @lport: The local port whose skbs are to be cleared |
Joe Eykholt | e7a5199 | 2009-08-25 14:04:08 -0700 | [diff] [blame] | 2071 | * |
| 2072 | * Must be called with fcoe_create_mutex held to single-thread completion. |
| 2073 | * |
| 2074 | * This flushes the pending skbs by adding a new skb to each queue and |
| 2075 | * waiting until they are all freed. This assures us that not only are |
| 2076 | * there no packets that will be handled by the lport, but also that any |
| 2077 | * threads already handling packet have returned. |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2078 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2079 | void fcoe_percpu_clean(struct fc_lport *lport) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2080 | { |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2081 | struct fcoe_percpu_s *pp; |
| 2082 | struct fcoe_rcv_info *fr; |
| 2083 | struct sk_buff_head *list; |
| 2084 | struct sk_buff *skb, *next; |
| 2085 | struct sk_buff *head; |
Robert Love | 5e5e92d | 2009-03-17 11:41:35 -0700 | [diff] [blame] | 2086 | unsigned int cpu; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2087 | |
Robert Love | 5e5e92d | 2009-03-17 11:41:35 -0700 | [diff] [blame] | 2088 | for_each_possible_cpu(cpu) { |
| 2089 | pp = &per_cpu(fcoe_percpu, cpu); |
| 2090 | spin_lock_bh(&pp->fcoe_rx_list.lock); |
| 2091 | list = &pp->fcoe_rx_list; |
| 2092 | head = list->next; |
| 2093 | for (skb = head; skb != (struct sk_buff *)list; |
| 2094 | skb = next) { |
| 2095 | next = skb->next; |
| 2096 | fr = fcoe_dev_from_skb(skb); |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2097 | if (fr->fr_dev == lport) { |
Robert Love | 5e5e92d | 2009-03-17 11:41:35 -0700 | [diff] [blame] | 2098 | __skb_unlink(skb, list); |
| 2099 | kfree_skb(skb); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2100 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2101 | } |
Joe Eykholt | e7a5199 | 2009-08-25 14:04:08 -0700 | [diff] [blame] | 2102 | |
| 2103 | if (!pp->thread || !cpu_online(cpu)) { |
| 2104 | spin_unlock_bh(&pp->fcoe_rx_list.lock); |
| 2105 | continue; |
| 2106 | } |
| 2107 | |
| 2108 | skb = dev_alloc_skb(0); |
| 2109 | if (!skb) { |
| 2110 | spin_unlock_bh(&pp->fcoe_rx_list.lock); |
| 2111 | continue; |
| 2112 | } |
| 2113 | skb->destructor = fcoe_percpu_flush_done; |
| 2114 | |
| 2115 | __skb_queue_tail(&pp->fcoe_rx_list, skb); |
| 2116 | if (pp->fcoe_rx_list.qlen == 1) |
| 2117 | wake_up_process(pp->thread); |
Robert Love | 5e5e92d | 2009-03-17 11:41:35 -0700 | [diff] [blame] | 2118 | spin_unlock_bh(&pp->fcoe_rx_list.lock); |
Joe Eykholt | e7a5199 | 2009-08-25 14:04:08 -0700 | [diff] [blame] | 2119 | |
| 2120 | wait_for_completion(&fcoe_flush_completion); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2121 | } |
| 2122 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2123 | |
| 2124 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2125 | * fcoe_reset() - Reset a local port |
| 2126 | * @shost: The SCSI host associated with the local port to be reset |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2127 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2128 | * Returns: Always 0 (return value required by FC transport template) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2129 | */ |
| 2130 | int fcoe_reset(struct Scsi_Host *shost) |
| 2131 | { |
| 2132 | struct fc_lport *lport = shost_priv(shost); |
| 2133 | fc_lport_reset(lport); |
| 2134 | return 0; |
| 2135 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2136 | |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 2137 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2138 | * fcoe_hostlist_lookup_port() - Find the FCoE interface associated with a net device |
| 2139 | * @netdev: The net device used as a key |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2140 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2141 | * Locking: Must be called with the RNL mutex held. |
| 2142 | * |
| 2143 | * Returns: NULL or the FCoE interface |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2144 | */ |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2145 | static struct fcoe_interface * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2146 | fcoe_hostlist_lookup_port(const struct net_device *netdev) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2147 | { |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2148 | struct fcoe_interface *fcoe; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2149 | |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2150 | list_for_each_entry(fcoe, &fcoe_hostlist, list) { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2151 | if (fcoe->netdev == netdev) |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2152 | return fcoe; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2153 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2154 | return NULL; |
| 2155 | } |
| 2156 | |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 2157 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2158 | * fcoe_hostlist_lookup() - Find the local port associated with a |
| 2159 | * given net device |
| 2160 | * @netdev: The netdevice used as a key |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2161 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2162 | * Locking: Must be called with the RTNL mutex held |
| 2163 | * |
| 2164 | * Returns: NULL or the local port |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2165 | */ |
Chris Leech | 090eb6c | 2009-08-25 14:00:28 -0700 | [diff] [blame] | 2166 | static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2167 | { |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2168 | struct fcoe_interface *fcoe; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2169 | |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2170 | fcoe = fcoe_hostlist_lookup_port(netdev); |
Chris Leech | 3fe9a0b | 2009-08-25 13:59:46 -0700 | [diff] [blame] | 2171 | return (fcoe) ? fcoe->ctlr.lp : NULL; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2172 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2173 | |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 2174 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2175 | * fcoe_hostlist_add() - Add the FCoE interface identified by a local |
| 2176 | * port to the hostlist |
| 2177 | * @lport: The local port that identifies the FCoE interface to be added |
| 2178 | * |
| 2179 | * Locking: must be called with the RTNL mutex held |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2180 | * |
| 2181 | * Returns: 0 for success |
| 2182 | */ |
Chris Leech | 090eb6c | 2009-08-25 14:00:28 -0700 | [diff] [blame] | 2183 | static int fcoe_hostlist_add(const struct fc_lport *lport) |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2184 | { |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2185 | struct fcoe_interface *fcoe; |
| 2186 | struct fcoe_port *port; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2187 | |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2188 | fcoe = fcoe_hostlist_lookup_port(fcoe_netdev(lport)); |
| 2189 | if (!fcoe) { |
| 2190 | port = lport_priv(lport); |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 2191 | fcoe = port->priv; |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2192 | list_add_tail(&fcoe->list, &fcoe_hostlist); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2193 | } |
| 2194 | return 0; |
| 2195 | } |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2196 | |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 2197 | |
| 2198 | static struct fcoe_transport fcoe_sw_transport = { |
| 2199 | .name = {FCOE_TRANSPORT_DEFAULT}, |
| 2200 | .attached = false, |
| 2201 | .list = LIST_HEAD_INIT(fcoe_sw_transport.list), |
| 2202 | .match = fcoe_match, |
| 2203 | .create = fcoe_create, |
| 2204 | .destroy = fcoe_destroy, |
| 2205 | .enable = fcoe_enable, |
| 2206 | .disable = fcoe_disable, |
| 2207 | }; |
| 2208 | |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 2209 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2210 | * fcoe_init() - Initialize fcoe.ko |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2211 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2212 | * Returns: 0 on success, or a negative value on failure |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 2213 | */ |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2214 | static int __init fcoe_init(void) |
| 2215 | { |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2216 | struct fcoe_percpu_s *p; |
Robert Love | 38eccab | 2009-03-17 11:41:30 -0700 | [diff] [blame] | 2217 | unsigned int cpu; |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 2218 | int rc = 0; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2219 | |
Tejun Heo | 2ca32b4 | 2011-01-28 16:05:32 -0800 | [diff] [blame] | 2220 | fcoe_wq = alloc_workqueue("fcoe", 0, 0); |
| 2221 | if (!fcoe_wq) |
| 2222 | return -ENOMEM; |
| 2223 | |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 2224 | /* register as a fcoe transport */ |
| 2225 | rc = fcoe_transport_attach(&fcoe_sw_transport); |
| 2226 | if (rc) { |
| 2227 | printk(KERN_ERR "failed to register an fcoe transport, check " |
| 2228 | "if libfcoe is loaded\n"); |
| 2229 | return rc; |
| 2230 | } |
| 2231 | |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 2232 | mutex_lock(&fcoe_config_mutex); |
| 2233 | |
Robert Love | 38eccab | 2009-03-17 11:41:30 -0700 | [diff] [blame] | 2234 | for_each_possible_cpu(cpu) { |
Robert Love | 5e5e92d | 2009-03-17 11:41:35 -0700 | [diff] [blame] | 2235 | p = &per_cpu(fcoe_percpu, cpu); |
Robert Love | 38eccab | 2009-03-17 11:41:30 -0700 | [diff] [blame] | 2236 | skb_queue_head_init(&p->fcoe_rx_list); |
| 2237 | } |
| 2238 | |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 2239 | for_each_online_cpu(cpu) |
| 2240 | fcoe_percpu_thread_create(cpu); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2241 | |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 2242 | /* Initialize per CPU interrupt thread */ |
| 2243 | rc = register_hotcpu_notifier(&fcoe_cpu_notifier); |
| 2244 | if (rc) |
| 2245 | goto out_free; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2246 | |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 2247 | /* Setup link change notification */ |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2248 | fcoe_dev_setup(); |
| 2249 | |
Chris Leech | 5892c32 | 2009-08-25 13:59:14 -0700 | [diff] [blame] | 2250 | rc = fcoe_if_init(); |
| 2251 | if (rc) |
| 2252 | goto out_free; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2253 | |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 2254 | mutex_unlock(&fcoe_config_mutex); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2255 | return 0; |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 2256 | |
| 2257 | out_free: |
| 2258 | for_each_online_cpu(cpu) { |
| 2259 | fcoe_percpu_thread_destroy(cpu); |
| 2260 | } |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 2261 | mutex_unlock(&fcoe_config_mutex); |
Tejun Heo | 2ca32b4 | 2011-01-28 16:05:32 -0800 | [diff] [blame] | 2262 | destroy_workqueue(fcoe_wq); |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 2263 | return rc; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2264 | } |
| 2265 | module_init(fcoe_init); |
| 2266 | |
| 2267 | /** |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2268 | * fcoe_exit() - Clean up fcoe.ko |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2269 | * |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2270 | * Returns: 0 on success or a negative value on failure |
Robert Love | 34f42a0 | 2009-02-27 10:55:45 -0800 | [diff] [blame] | 2271 | */ |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2272 | static void __exit fcoe_exit(void) |
| 2273 | { |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2274 | struct fcoe_interface *fcoe, *tmp; |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 2275 | struct fcoe_port *port; |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2276 | unsigned int cpu; |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2277 | |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 2278 | mutex_lock(&fcoe_config_mutex); |
| 2279 | |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2280 | fcoe_dev_cleanup(); |
| 2281 | |
Vasu Dev | 5919a59 | 2009-03-27 09:03:29 -0700 | [diff] [blame] | 2282 | /* releases the associated fcoe hosts */ |
Chris Leech | 090eb6c | 2009-08-25 14:00:28 -0700 | [diff] [blame] | 2283 | rtnl_lock(); |
| 2284 | list_for_each_entry_safe(fcoe, tmp, &fcoe_hostlist, list) { |
Chris Leech | c863df3 | 2009-08-25 14:00:18 -0700 | [diff] [blame] | 2285 | list_del(&fcoe->list); |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 2286 | port = lport_priv(fcoe->ctlr.lp); |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 2287 | fcoe_interface_cleanup(fcoe); |
Tejun Heo | 2ca32b4 | 2011-01-28 16:05:32 -0800 | [diff] [blame] | 2288 | queue_work(fcoe_wq, &port->destroy_work); |
Chris Leech | c863df3 | 2009-08-25 14:00:18 -0700 | [diff] [blame] | 2289 | } |
Chris Leech | 090eb6c | 2009-08-25 14:00:28 -0700 | [diff] [blame] | 2290 | rtnl_unlock(); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2291 | |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 2292 | unregister_hotcpu_notifier(&fcoe_cpu_notifier); |
| 2293 | |
Chris Leech | 014f5c3 | 2009-08-25 13:59:30 -0700 | [diff] [blame] | 2294 | for_each_online_cpu(cpu) |
Robert Love | 8976f42 | 2009-03-17 11:41:46 -0700 | [diff] [blame] | 2295 | fcoe_percpu_thread_destroy(cpu); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2296 | |
Chris Leech | dfc1d0f | 2009-08-25 14:00:13 -0700 | [diff] [blame] | 2297 | mutex_unlock(&fcoe_config_mutex); |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 2298 | |
Tejun Heo | 2ca32b4 | 2011-01-28 16:05:32 -0800 | [diff] [blame] | 2299 | /* |
| 2300 | * destroy_work's may be chained but destroy_workqueue() |
| 2301 | * can take care of them. Just kill the fcoe_wq. |
| 2302 | */ |
| 2303 | destroy_workqueue(fcoe_wq); |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 2304 | |
Tejun Heo | 2ca32b4 | 2011-01-28 16:05:32 -0800 | [diff] [blame] | 2305 | /* |
| 2306 | * Detaching from the scsi transport must happen after all |
| 2307 | * destroys are done on the fcoe_wq. destroy_workqueue will |
| 2308 | * enusre the fcoe_wq is flushed. |
| 2309 | */ |
Chris Leech | 2e70e24 | 2009-08-25 14:00:23 -0700 | [diff] [blame] | 2310 | fcoe_if_exit(); |
Yi Zou | 78a5824 | 2011-01-28 16:05:16 -0800 | [diff] [blame] | 2311 | |
| 2312 | /* detach from fcoe transport */ |
| 2313 | fcoe_transport_detach(&fcoe_sw_transport); |
Robert Love | 85b4aa4 | 2008-12-09 15:10:24 -0800 | [diff] [blame] | 2314 | } |
| 2315 | module_exit(fcoe_exit); |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2316 | |
| 2317 | /** |
| 2318 | * fcoe_flogi_resp() - FCoE specific FLOGI and FDISC response handler |
| 2319 | * @seq: active sequence in the FLOGI or FDISC exchange |
| 2320 | * @fp: response frame, or error encoded in a pointer (timeout) |
| 2321 | * @arg: pointer the the fcoe_ctlr structure |
| 2322 | * |
Uwe Kleine-König | 65155b3 | 2010-06-11 12:17:01 +0200 | [diff] [blame] | 2323 | * This handles MAC address management for FCoE, then passes control on to |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2324 | * the libfc FLOGI response handler. |
| 2325 | */ |
| 2326 | static void fcoe_flogi_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) |
| 2327 | { |
| 2328 | struct fcoe_ctlr *fip = arg; |
| 2329 | struct fc_exch *exch = fc_seq_exch(seq); |
| 2330 | struct fc_lport *lport = exch->lp; |
| 2331 | u8 *mac; |
| 2332 | |
| 2333 | if (IS_ERR(fp)) |
| 2334 | goto done; |
| 2335 | |
| 2336 | mac = fr_cb(fp)->granted_mac; |
| 2337 | if (is_zero_ether_addr(mac)) { |
| 2338 | /* pre-FIP */ |
Joe Eykholt | 386309ce | 2009-11-03 11:49:16 -0800 | [diff] [blame] | 2339 | if (fcoe_ctlr_recv_flogi(fip, lport, fp)) { |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2340 | fc_frame_free(fp); |
| 2341 | return; |
| 2342 | } |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2343 | } |
Joe Eykholt | 386309ce | 2009-11-03 11:49:16 -0800 | [diff] [blame] | 2344 | fcoe_update_src_mac(lport, mac); |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2345 | done: |
| 2346 | fc_lport_flogi_resp(seq, fp, lport); |
| 2347 | } |
| 2348 | |
| 2349 | /** |
| 2350 | * fcoe_logo_resp() - FCoE specific LOGO response handler |
| 2351 | * @seq: active sequence in the LOGO exchange |
| 2352 | * @fp: response frame, or error encoded in a pointer (timeout) |
| 2353 | * @arg: pointer the the fcoe_ctlr structure |
| 2354 | * |
Uwe Kleine-König | 65155b3 | 2010-06-11 12:17:01 +0200 | [diff] [blame] | 2355 | * This handles MAC address management for FCoE, then passes control on to |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2356 | * the libfc LOGO response handler. |
| 2357 | */ |
| 2358 | static void fcoe_logo_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) |
| 2359 | { |
Joe Eykholt | 386309ce | 2009-11-03 11:49:16 -0800 | [diff] [blame] | 2360 | struct fc_lport *lport = arg; |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2361 | static u8 zero_mac[ETH_ALEN] = { 0 }; |
| 2362 | |
| 2363 | if (!IS_ERR(fp)) |
Joe Eykholt | 386309ce | 2009-11-03 11:49:16 -0800 | [diff] [blame] | 2364 | fcoe_update_src_mac(lport, zero_mac); |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2365 | fc_lport_logo_resp(seq, fp, lport); |
| 2366 | } |
| 2367 | |
| 2368 | /** |
| 2369 | * fcoe_elsct_send - FCoE specific ELS handler |
| 2370 | * |
| 2371 | * This does special case handling of FIP encapsualted ELS exchanges for FCoE, |
| 2372 | * using FCoE specific response handlers and passing the FIP controller as |
| 2373 | * the argument (the lport is still available from the exchange). |
| 2374 | * |
| 2375 | * Most of the work here is just handed off to the libfc routine. |
| 2376 | */ |
Robert Love | 1875f27 | 2009-11-03 11:47:50 -0800 | [diff] [blame] | 2377 | static struct fc_seq *fcoe_elsct_send(struct fc_lport *lport, u32 did, |
| 2378 | struct fc_frame *fp, unsigned int op, |
| 2379 | void (*resp)(struct fc_seq *, |
| 2380 | struct fc_frame *, |
| 2381 | void *), |
| 2382 | void *arg, u32 timeout) |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2383 | { |
| 2384 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 2385 | struct fcoe_interface *fcoe = port->priv; |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2386 | struct fcoe_ctlr *fip = &fcoe->ctlr; |
| 2387 | struct fc_frame_header *fh = fc_frame_header_get(fp); |
| 2388 | |
| 2389 | switch (op) { |
| 2390 | case ELS_FLOGI: |
| 2391 | case ELS_FDISC: |
Joe Eykholt | e10f8c6 | 2010-07-20 15:20:30 -0700 | [diff] [blame] | 2392 | if (lport->point_to_multipoint) |
| 2393 | break; |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2394 | return fc_elsct_send(lport, did, fp, op, fcoe_flogi_resp, |
| 2395 | fip, timeout); |
| 2396 | case ELS_LOGO: |
| 2397 | /* only hook onto fabric logouts, not port logouts */ |
| 2398 | if (ntoh24(fh->fh_d_id) != FC_FID_FLOGI) |
| 2399 | break; |
| 2400 | return fc_elsct_send(lport, did, fp, op, fcoe_logo_resp, |
Joe Eykholt | 386309ce | 2009-11-03 11:49:16 -0800 | [diff] [blame] | 2401 | lport, timeout); |
Chris Leech | 11b5618 | 2009-11-03 11:46:29 -0800 | [diff] [blame] | 2402 | } |
| 2403 | return fc_elsct_send(lport, did, fp, op, resp, arg, timeout); |
| 2404 | } |
| 2405 | |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 2406 | /** |
| 2407 | * fcoe_vport_create() - create an fc_host/scsi_host for a vport |
| 2408 | * @vport: fc_vport object to create a new fc_host for |
| 2409 | * @disabled: start the new fc_host in a disabled state by default? |
| 2410 | * |
| 2411 | * Returns: 0 for success |
| 2412 | */ |
| 2413 | static int fcoe_vport_create(struct fc_vport *vport, bool disabled) |
| 2414 | { |
| 2415 | struct Scsi_Host *shost = vport_to_shost(vport); |
| 2416 | struct fc_lport *n_port = shost_priv(shost); |
| 2417 | struct fcoe_port *port = lport_priv(n_port); |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 2418 | struct fcoe_interface *fcoe = port->priv; |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 2419 | struct net_device *netdev = fcoe->netdev; |
| 2420 | struct fc_lport *vn_port; |
| 2421 | |
| 2422 | mutex_lock(&fcoe_config_mutex); |
| 2423 | vn_port = fcoe_if_create(fcoe, &vport->dev, 1); |
| 2424 | mutex_unlock(&fcoe_config_mutex); |
| 2425 | |
| 2426 | if (IS_ERR(vn_port)) { |
| 2427 | printk(KERN_ERR "fcoe: fcoe_vport_create(%s) failed\n", |
| 2428 | netdev->name); |
| 2429 | return -EIO; |
| 2430 | } |
| 2431 | |
| 2432 | if (disabled) { |
| 2433 | fc_vport_set_state(vport, FC_VPORT_DISABLED); |
| 2434 | } else { |
| 2435 | vn_port->boot_time = jiffies; |
| 2436 | fc_fabric_login(vn_port); |
| 2437 | fc_vport_setlink(vn_port); |
| 2438 | } |
| 2439 | return 0; |
| 2440 | } |
| 2441 | |
| 2442 | /** |
| 2443 | * fcoe_vport_destroy() - destroy the fc_host/scsi_host for a vport |
| 2444 | * @vport: fc_vport object that is being destroyed |
| 2445 | * |
| 2446 | * Returns: 0 for success |
| 2447 | */ |
| 2448 | static int fcoe_vport_destroy(struct fc_vport *vport) |
| 2449 | { |
| 2450 | struct Scsi_Host *shost = vport_to_shost(vport); |
| 2451 | struct fc_lport *n_port = shost_priv(shost); |
| 2452 | struct fc_lport *vn_port = vport->dd_data; |
| 2453 | struct fcoe_port *port = lport_priv(vn_port); |
| 2454 | |
| 2455 | mutex_lock(&n_port->lp_mutex); |
| 2456 | list_del(&vn_port->list); |
| 2457 | mutex_unlock(&n_port->lp_mutex); |
Tejun Heo | 2ca32b4 | 2011-01-28 16:05:32 -0800 | [diff] [blame] | 2458 | queue_work(fcoe_wq, &port->destroy_work); |
Chris Leech | 9a05753 | 2009-11-03 11:46:40 -0800 | [diff] [blame] | 2459 | return 0; |
| 2460 | } |
| 2461 | |
| 2462 | /** |
| 2463 | * fcoe_vport_disable() - change vport state |
| 2464 | * @vport: vport to bring online/offline |
| 2465 | * @disable: should the vport be disabled? |
| 2466 | */ |
| 2467 | static int fcoe_vport_disable(struct fc_vport *vport, bool disable) |
| 2468 | { |
| 2469 | struct fc_lport *lport = vport->dd_data; |
| 2470 | |
| 2471 | if (disable) { |
| 2472 | fc_vport_set_state(vport, FC_VPORT_DISABLED); |
| 2473 | fc_fabric_logoff(lport); |
| 2474 | } else { |
| 2475 | lport->boot_time = jiffies; |
| 2476 | fc_fabric_login(lport); |
| 2477 | fc_vport_setlink(lport); |
| 2478 | } |
| 2479 | |
| 2480 | return 0; |
| 2481 | } |
| 2482 | |
Chris Leech | dc8596d | 2009-11-03 11:47:18 -0800 | [diff] [blame] | 2483 | /** |
| 2484 | * fcoe_vport_set_symbolic_name() - append vport string to symbolic name |
| 2485 | * @vport: fc_vport with a new symbolic name string |
| 2486 | * |
| 2487 | * After generating a new symbolic name string, a new RSPN_ID request is |
| 2488 | * sent to the name server. There is no response handler, so if it fails |
| 2489 | * for some reason it will not be retried. |
| 2490 | */ |
| 2491 | static void fcoe_set_vport_symbolic_name(struct fc_vport *vport) |
| 2492 | { |
| 2493 | struct fc_lport *lport = vport->dd_data; |
| 2494 | struct fc_frame *fp; |
| 2495 | size_t len; |
| 2496 | |
| 2497 | snprintf(fc_host_symbolic_name(lport->host), FC_SYMBOLIC_NAME_SIZE, |
| 2498 | "%s v%s over %s : %s", FCOE_NAME, FCOE_VERSION, |
| 2499 | fcoe_netdev(lport)->name, vport->symbolic_name); |
| 2500 | |
| 2501 | if (lport->state != LPORT_ST_READY) |
| 2502 | return; |
| 2503 | |
| 2504 | len = strnlen(fc_host_symbolic_name(lport->host), 255); |
| 2505 | fp = fc_frame_alloc(lport, |
| 2506 | sizeof(struct fc_ct_hdr) + |
| 2507 | sizeof(struct fc_ns_rspn) + len); |
| 2508 | if (!fp) |
| 2509 | return; |
| 2510 | lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RSPN_ID, |
Joe Eykholt | b94f895 | 2009-11-03 11:50:21 -0800 | [diff] [blame] | 2511 | NULL, NULL, 3 * lport->r_a_tov); |
Chris Leech | dc8596d | 2009-11-03 11:47:18 -0800 | [diff] [blame] | 2512 | } |
Yi Zou | b84056b | 2009-11-20 14:55:19 -0800 | [diff] [blame] | 2513 | |
| 2514 | /** |
| 2515 | * fcoe_get_lesb() - Fill the FCoE Link Error Status Block |
| 2516 | * @lport: the local port |
| 2517 | * @fc_lesb: the link error status block |
| 2518 | */ |
| 2519 | static void fcoe_get_lesb(struct fc_lport *lport, |
| 2520 | struct fc_els_lesb *fc_lesb) |
| 2521 | { |
| 2522 | unsigned int cpu; |
| 2523 | u32 lfc, vlfc, mdac; |
| 2524 | struct fcoe_dev_stats *devst; |
| 2525 | struct fcoe_fc_els_lesb *lesb; |
Eric Dumazet | 2817273 | 2010-07-07 14:58:56 -0700 | [diff] [blame] | 2526 | struct rtnl_link_stats64 temp; |
Yi Zou | b84056b | 2009-11-20 14:55:19 -0800 | [diff] [blame] | 2527 | struct net_device *netdev = fcoe_netdev(lport); |
| 2528 | |
| 2529 | lfc = 0; |
| 2530 | vlfc = 0; |
| 2531 | mdac = 0; |
| 2532 | lesb = (struct fcoe_fc_els_lesb *)fc_lesb; |
| 2533 | memset(lesb, 0, sizeof(*lesb)); |
| 2534 | for_each_possible_cpu(cpu) { |
| 2535 | devst = per_cpu_ptr(lport->dev_stats, cpu); |
| 2536 | lfc += devst->LinkFailureCount; |
| 2537 | vlfc += devst->VLinkFailureCount; |
| 2538 | mdac += devst->MissDiscAdvCount; |
| 2539 | } |
| 2540 | lesb->lesb_link_fail = htonl(lfc); |
| 2541 | lesb->lesb_vlink_fail = htonl(vlfc); |
| 2542 | lesb->lesb_miss_fka = htonl(mdac); |
Eric Dumazet | 2817273 | 2010-07-07 14:58:56 -0700 | [diff] [blame] | 2543 | lesb->lesb_fcs_error = htonl(dev_get_stats(netdev, &temp)->rx_crc_errors); |
Yi Zou | b84056b | 2009-11-20 14:55:19 -0800 | [diff] [blame] | 2544 | } |
Joe Eykholt | 7d65b0d | 2010-03-12 16:08:02 -0800 | [diff] [blame] | 2545 | |
| 2546 | /** |
| 2547 | * fcoe_set_port_id() - Callback from libfc when Port_ID is set. |
| 2548 | * @lport: the local port |
| 2549 | * @port_id: the port ID |
| 2550 | * @fp: the received frame, if any, that caused the port_id to be set. |
| 2551 | * |
| 2552 | * This routine handles the case where we received a FLOGI and are |
| 2553 | * entering point-to-point mode. We need to call fcoe_ctlr_recv_flogi() |
| 2554 | * so it can set the non-mapped mode and gateway address. |
| 2555 | * |
| 2556 | * The FLOGI LS_ACC is handled by fcoe_flogi_resp(). |
| 2557 | */ |
| 2558 | static void fcoe_set_port_id(struct fc_lport *lport, |
| 2559 | u32 port_id, struct fc_frame *fp) |
| 2560 | { |
| 2561 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | 8597ae8 | 2011-01-28 16:05:37 -0800 | [diff] [blame] | 2562 | struct fcoe_interface *fcoe = port->priv; |
Joe Eykholt | 7d65b0d | 2010-03-12 16:08:02 -0800 | [diff] [blame] | 2563 | |
| 2564 | if (fp && fc_frame_payload_op(fp) == ELS_FLOGI) |
| 2565 | fcoe_ctlr_recv_flogi(&fcoe->ctlr, lport, fp); |
| 2566 | } |