Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1 | /* bnx2fc_fcoe.c: Broadcom NetXtreme II Linux FCoE offload driver. |
| 2 | * This file contains the code that interacts with libfc, libfcoe, |
| 3 | * cnic modules to create FCoE instances, send/receive non-offloaded |
| 4 | * FIP/FCoE packets, listen to link events etc. |
| 5 | * |
Bhanu Prakash Gollapudi | 9b35baa | 2011-07-27 11:32:13 -0700 | [diff] [blame] | 6 | * Copyright (c) 2008 - 2011 Broadcom Corporation |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation. |
| 11 | * |
| 12 | * Written by: Bhanu Prakash Gollapudi (bprakash@broadcom.com) |
| 13 | */ |
| 14 | |
| 15 | #include "bnx2fc.h" |
| 16 | |
| 17 | static struct list_head adapter_list; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 18 | static struct list_head if_list; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 19 | static u32 adapter_count; |
| 20 | static DEFINE_MUTEX(bnx2fc_dev_lock); |
| 21 | DEFINE_PER_CPU(struct bnx2fc_percpu_s, bnx2fc_percpu); |
| 22 | |
| 23 | #define DRV_MODULE_NAME "bnx2fc" |
| 24 | #define DRV_MODULE_VERSION BNX2FC_VERSION |
Bhanu Prakash Gollapudi | 55a3a35 | 2011-08-04 17:38:52 -0700 | [diff] [blame] | 25 | #define DRV_MODULE_RELDATE "Aug 03, 2011" |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 26 | |
| 27 | |
| 28 | static char version[] __devinitdata = |
| 29 | "Broadcom NetXtreme II FCoE Driver " DRV_MODULE_NAME \ |
| 30 | " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; |
| 31 | |
| 32 | |
| 33 | MODULE_AUTHOR("Bhanu Prakash Gollapudi <bprakash@broadcom.com>"); |
| 34 | MODULE_DESCRIPTION("Broadcom NetXtreme II BCM57710 FCoE Driver"); |
| 35 | MODULE_LICENSE("GPL"); |
| 36 | MODULE_VERSION(DRV_MODULE_VERSION); |
| 37 | |
| 38 | #define BNX2FC_MAX_QUEUE_DEPTH 256 |
| 39 | #define BNX2FC_MIN_QUEUE_DEPTH 32 |
| 40 | #define FCOE_WORD_TO_BYTE 4 |
| 41 | |
| 42 | static struct scsi_transport_template *bnx2fc_transport_template; |
| 43 | static struct scsi_transport_template *bnx2fc_vport_xport_template; |
| 44 | |
| 45 | struct workqueue_struct *bnx2fc_wq; |
| 46 | |
| 47 | /* bnx2fc structure needs only one instance of the fcoe_percpu_s structure. |
| 48 | * Here the io threads are per cpu but the l2 thread is just one |
| 49 | */ |
| 50 | struct fcoe_percpu_s bnx2fc_global; |
| 51 | DEFINE_SPINLOCK(bnx2fc_global_lock); |
| 52 | |
| 53 | static struct cnic_ulp_ops bnx2fc_cnic_cb; |
| 54 | static struct libfc_function_template bnx2fc_libfc_fcn_templ; |
| 55 | static struct scsi_host_template bnx2fc_shost_template; |
| 56 | static struct fc_function_template bnx2fc_transport_function; |
| 57 | static struct fc_function_template bnx2fc_vport_xport_function; |
| 58 | static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode); |
Bhanu Prakash Gollapudi | eccdcd0 | 2011-08-24 18:56:42 -0700 | [diff] [blame^] | 59 | static void __bnx2fc_destroy(struct bnx2fc_interface *interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 60 | static int bnx2fc_destroy(struct net_device *net_device); |
| 61 | static int bnx2fc_enable(struct net_device *netdev); |
| 62 | static int bnx2fc_disable(struct net_device *netdev); |
| 63 | |
| 64 | static void bnx2fc_recv_frame(struct sk_buff *skb); |
| 65 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 66 | static void bnx2fc_start_disc(struct bnx2fc_interface *interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 67 | static int bnx2fc_shost_config(struct fc_lport *lport, struct device *dev); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 68 | static int bnx2fc_lport_config(struct fc_lport *lport); |
| 69 | static int bnx2fc_em_config(struct fc_lport *lport); |
| 70 | static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba); |
| 71 | static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba); |
| 72 | static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba); |
| 73 | static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 74 | static struct fc_lport *bnx2fc_if_create(struct bnx2fc_interface *interface, |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 75 | struct device *parent, int npiv); |
| 76 | static void bnx2fc_destroy_work(struct work_struct *work); |
| 77 | |
| 78 | static struct bnx2fc_hba *bnx2fc_hba_lookup(struct net_device *phys_dev); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 79 | static struct bnx2fc_interface *bnx2fc_interface_lookup(struct net_device |
| 80 | *phys_dev); |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 81 | static inline void bnx2fc_interface_put(struct bnx2fc_interface *interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 82 | static struct bnx2fc_hba *bnx2fc_find_hba_for_cnic(struct cnic_dev *cnic); |
| 83 | |
| 84 | static int bnx2fc_fw_init(struct bnx2fc_hba *hba); |
| 85 | static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba); |
| 86 | |
| 87 | static void bnx2fc_port_shutdown(struct fc_lport *lport); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 88 | static void bnx2fc_stop(struct bnx2fc_interface *interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 89 | static int __init bnx2fc_mod_init(void); |
| 90 | static void __exit bnx2fc_mod_exit(void); |
| 91 | |
| 92 | unsigned int bnx2fc_debug_level; |
| 93 | module_param_named(debug_logging, bnx2fc_debug_level, int, S_IRUGO|S_IWUSR); |
| 94 | |
| 95 | static int bnx2fc_cpu_callback(struct notifier_block *nfb, |
| 96 | unsigned long action, void *hcpu); |
| 97 | /* notification function for CPU hotplug events */ |
| 98 | static struct notifier_block bnx2fc_cpu_notifier = { |
| 99 | .notifier_call = bnx2fc_cpu_callback, |
| 100 | }; |
| 101 | |
| 102 | static void bnx2fc_clean_rx_queue(struct fc_lport *lp) |
| 103 | { |
| 104 | struct fcoe_percpu_s *bg; |
| 105 | struct fcoe_rcv_info *fr; |
| 106 | struct sk_buff_head *list; |
| 107 | struct sk_buff *skb, *next; |
| 108 | struct sk_buff *head; |
| 109 | |
| 110 | bg = &bnx2fc_global; |
| 111 | spin_lock_bh(&bg->fcoe_rx_list.lock); |
| 112 | list = &bg->fcoe_rx_list; |
| 113 | head = list->next; |
| 114 | for (skb = head; skb != (struct sk_buff *)list; |
| 115 | skb = next) { |
| 116 | next = skb->next; |
| 117 | fr = fcoe_dev_from_skb(skb); |
| 118 | if (fr->fr_dev == lp) { |
| 119 | __skb_unlink(skb, list); |
| 120 | kfree_skb(skb); |
| 121 | } |
| 122 | } |
| 123 | spin_unlock_bh(&bg->fcoe_rx_list.lock); |
| 124 | } |
| 125 | |
| 126 | int bnx2fc_get_paged_crc_eof(struct sk_buff *skb, int tlen) |
| 127 | { |
| 128 | int rc; |
| 129 | spin_lock(&bnx2fc_global_lock); |
| 130 | rc = fcoe_get_paged_crc_eof(skb, tlen, &bnx2fc_global); |
| 131 | spin_unlock(&bnx2fc_global_lock); |
| 132 | |
| 133 | return rc; |
| 134 | } |
| 135 | |
| 136 | static void bnx2fc_abort_io(struct fc_lport *lport) |
| 137 | { |
| 138 | /* |
| 139 | * This function is no-op for bnx2fc, but we do |
| 140 | * not want to leave it as NULL either, as libfc |
| 141 | * can call the default function which is |
| 142 | * fc_fcp_abort_io. |
| 143 | */ |
| 144 | } |
| 145 | |
| 146 | static void bnx2fc_cleanup(struct fc_lport *lport) |
| 147 | { |
| 148 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 149 | struct bnx2fc_interface *interface = port->priv; |
| 150 | struct bnx2fc_hba *hba = interface->hba; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 151 | struct bnx2fc_rport *tgt; |
| 152 | int i; |
| 153 | |
| 154 | BNX2FC_MISC_DBG("Entered %s\n", __func__); |
| 155 | mutex_lock(&hba->hba_mutex); |
| 156 | spin_lock_bh(&hba->hba_lock); |
| 157 | for (i = 0; i < BNX2FC_NUM_MAX_SESS; i++) { |
| 158 | tgt = hba->tgt_ofld_list[i]; |
| 159 | if (tgt) { |
| 160 | /* Cleanup IOs belonging to requested vport */ |
| 161 | if (tgt->port == port) { |
| 162 | spin_unlock_bh(&hba->hba_lock); |
| 163 | BNX2FC_TGT_DBG(tgt, "flush/cleanup\n"); |
| 164 | bnx2fc_flush_active_ios(tgt); |
| 165 | spin_lock_bh(&hba->hba_lock); |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | spin_unlock_bh(&hba->hba_lock); |
| 170 | mutex_unlock(&hba->hba_mutex); |
| 171 | } |
| 172 | |
| 173 | static int bnx2fc_xmit_l2_frame(struct bnx2fc_rport *tgt, |
| 174 | struct fc_frame *fp) |
| 175 | { |
| 176 | struct fc_rport_priv *rdata = tgt->rdata; |
| 177 | struct fc_frame_header *fh; |
| 178 | int rc = 0; |
| 179 | |
| 180 | fh = fc_frame_header_get(fp); |
| 181 | BNX2FC_TGT_DBG(tgt, "Xmit L2 frame rport = 0x%x, oxid = 0x%x, " |
| 182 | "r_ctl = 0x%x\n", rdata->ids.port_id, |
| 183 | ntohs(fh->fh_ox_id), fh->fh_r_ctl); |
| 184 | if ((fh->fh_type == FC_TYPE_ELS) && |
| 185 | (fh->fh_r_ctl == FC_RCTL_ELS_REQ)) { |
| 186 | |
| 187 | switch (fc_frame_payload_op(fp)) { |
| 188 | case ELS_ADISC: |
| 189 | rc = bnx2fc_send_adisc(tgt, fp); |
| 190 | break; |
| 191 | case ELS_LOGO: |
| 192 | rc = bnx2fc_send_logo(tgt, fp); |
| 193 | break; |
| 194 | case ELS_RLS: |
| 195 | rc = bnx2fc_send_rls(tgt, fp); |
| 196 | break; |
| 197 | default: |
| 198 | break; |
| 199 | } |
| 200 | } else if ((fh->fh_type == FC_TYPE_BLS) && |
| 201 | (fh->fh_r_ctl == FC_RCTL_BA_ABTS)) |
| 202 | BNX2FC_TGT_DBG(tgt, "ABTS frame\n"); |
| 203 | else { |
| 204 | BNX2FC_TGT_DBG(tgt, "Send L2 frame type 0x%x " |
| 205 | "rctl 0x%x thru non-offload path\n", |
| 206 | fh->fh_type, fh->fh_r_ctl); |
| 207 | return -ENODEV; |
| 208 | } |
| 209 | if (rc) |
| 210 | return -ENOMEM; |
| 211 | else |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * bnx2fc_xmit - bnx2fc's FCoE frame transmit function |
| 217 | * |
| 218 | * @lport: the associated local port |
| 219 | * @fp: the fc_frame to be transmitted |
| 220 | */ |
| 221 | static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) |
| 222 | { |
| 223 | struct ethhdr *eh; |
| 224 | struct fcoe_crc_eof *cp; |
| 225 | struct sk_buff *skb; |
| 226 | struct fc_frame_header *fh; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 227 | struct bnx2fc_interface *interface; |
| 228 | struct bnx2fc_hba *hba; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 229 | struct fcoe_port *port; |
| 230 | struct fcoe_hdr *hp; |
| 231 | struct bnx2fc_rport *tgt; |
| 232 | struct fcoe_dev_stats *stats; |
| 233 | u8 sof, eof; |
| 234 | u32 crc; |
| 235 | unsigned int hlen, tlen, elen; |
| 236 | int wlen, rc = 0; |
| 237 | |
| 238 | port = (struct fcoe_port *)lport_priv(lport); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 239 | interface = port->priv; |
| 240 | hba = interface->hba; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 241 | |
| 242 | fh = fc_frame_header_get(fp); |
| 243 | |
| 244 | skb = fp_skb(fp); |
| 245 | if (!lport->link_up) { |
| 246 | BNX2FC_HBA_DBG(lport, "bnx2fc_xmit link down\n"); |
| 247 | kfree_skb(skb); |
| 248 | return 0; |
| 249 | } |
| 250 | |
| 251 | if (unlikely(fh->fh_r_ctl == FC_RCTL_ELS_REQ)) { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 252 | if (!interface->ctlr.sel_fcf) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 253 | BNX2FC_HBA_DBG(lport, "FCF not selected yet!\n"); |
| 254 | kfree_skb(skb); |
| 255 | return -EINVAL; |
| 256 | } |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 257 | if (fcoe_ctlr_els_send(&interface->ctlr, lport, skb)) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 258 | return 0; |
| 259 | } |
| 260 | |
| 261 | sof = fr_sof(fp); |
| 262 | eof = fr_eof(fp); |
| 263 | |
| 264 | /* |
| 265 | * Snoop the frame header to check if the frame is for |
| 266 | * an offloaded session |
| 267 | */ |
| 268 | /* |
| 269 | * tgt_ofld_list access is synchronized using |
| 270 | * both hba mutex and hba lock. Atleast hba mutex or |
| 271 | * hba lock needs to be held for read access. |
| 272 | */ |
| 273 | |
| 274 | spin_lock_bh(&hba->hba_lock); |
| 275 | tgt = bnx2fc_tgt_lookup(port, ntoh24(fh->fh_d_id)); |
| 276 | if (tgt && (test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags))) { |
| 277 | /* This frame is for offloaded session */ |
| 278 | BNX2FC_HBA_DBG(lport, "xmit: Frame is for offloaded session " |
| 279 | "port_id = 0x%x\n", ntoh24(fh->fh_d_id)); |
| 280 | spin_unlock_bh(&hba->hba_lock); |
| 281 | rc = bnx2fc_xmit_l2_frame(tgt, fp); |
| 282 | if (rc != -ENODEV) { |
| 283 | kfree_skb(skb); |
| 284 | return rc; |
| 285 | } |
| 286 | } else { |
| 287 | spin_unlock_bh(&hba->hba_lock); |
| 288 | } |
| 289 | |
| 290 | elen = sizeof(struct ethhdr); |
| 291 | hlen = sizeof(struct fcoe_hdr); |
| 292 | tlen = sizeof(struct fcoe_crc_eof); |
| 293 | wlen = (skb->len - tlen + sizeof(crc)) / FCOE_WORD_TO_BYTE; |
| 294 | |
| 295 | skb->ip_summed = CHECKSUM_NONE; |
| 296 | crc = fcoe_fc_crc(fp); |
| 297 | |
| 298 | /* copy port crc and eof to the skb buff */ |
| 299 | if (skb_is_nonlinear(skb)) { |
| 300 | skb_frag_t *frag; |
| 301 | if (bnx2fc_get_paged_crc_eof(skb, tlen)) { |
| 302 | kfree_skb(skb); |
| 303 | return -ENOMEM; |
| 304 | } |
| 305 | frag = &skb_shinfo(skb)->frags[skb_shinfo(skb)->nr_frags - 1]; |
| 306 | cp = kmap_atomic(frag->page, KM_SKB_DATA_SOFTIRQ) |
| 307 | + frag->page_offset; |
| 308 | } else { |
| 309 | cp = (struct fcoe_crc_eof *)skb_put(skb, tlen); |
| 310 | } |
| 311 | |
| 312 | memset(cp, 0, sizeof(*cp)); |
| 313 | cp->fcoe_eof = eof; |
| 314 | cp->fcoe_crc32 = cpu_to_le32(~crc); |
| 315 | if (skb_is_nonlinear(skb)) { |
| 316 | kunmap_atomic(cp, KM_SKB_DATA_SOFTIRQ); |
| 317 | cp = NULL; |
| 318 | } |
| 319 | |
| 320 | /* adjust skb network/transport offsets to match mac/fcoe/port */ |
| 321 | skb_push(skb, elen + hlen); |
| 322 | skb_reset_mac_header(skb); |
| 323 | skb_reset_network_header(skb); |
| 324 | skb->mac_len = elen; |
| 325 | skb->protocol = htons(ETH_P_FCOE); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 326 | skb->dev = interface->netdev; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 327 | |
| 328 | /* fill up mac and fcoe headers */ |
| 329 | eh = eth_hdr(skb); |
| 330 | eh->h_proto = htons(ETH_P_FCOE); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 331 | if (interface->ctlr.map_dest) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 332 | fc_fcoe_set_mac(eh->h_dest, fh->fh_d_id); |
| 333 | else |
| 334 | /* insert GW address */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 335 | memcpy(eh->h_dest, interface->ctlr.dest_addr, ETH_ALEN); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 336 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 337 | if (unlikely(interface->ctlr.flogi_oxid != FC_XID_UNKNOWN)) |
| 338 | memcpy(eh->h_source, interface->ctlr.ctl_src_addr, ETH_ALEN); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 339 | else |
| 340 | memcpy(eh->h_source, port->data_src_addr, ETH_ALEN); |
| 341 | |
| 342 | hp = (struct fcoe_hdr *)(eh + 1); |
| 343 | memset(hp, 0, sizeof(*hp)); |
| 344 | if (FC_FCOE_VER) |
| 345 | FC_FCOE_ENCAPS_VER(hp, FC_FCOE_VER); |
| 346 | hp->fcoe_sof = sof; |
| 347 | |
| 348 | /* fcoe lso, mss is in max_payload which is non-zero for FCP data */ |
| 349 | if (lport->seq_offload && fr_max_payload(fp)) { |
| 350 | skb_shinfo(skb)->gso_type = SKB_GSO_FCOE; |
| 351 | skb_shinfo(skb)->gso_size = fr_max_payload(fp); |
| 352 | } else { |
| 353 | skb_shinfo(skb)->gso_type = 0; |
| 354 | skb_shinfo(skb)->gso_size = 0; |
| 355 | } |
| 356 | |
| 357 | /*update tx stats */ |
| 358 | stats = per_cpu_ptr(lport->dev_stats, get_cpu()); |
| 359 | stats->TxFrames++; |
| 360 | stats->TxWords += wlen; |
| 361 | put_cpu(); |
| 362 | |
| 363 | /* send down to lld */ |
| 364 | fr_dev(fp) = lport; |
| 365 | if (port->fcoe_pending_queue.qlen) |
| 366 | fcoe_check_wait_queue(lport, skb); |
| 367 | else if (fcoe_start_io(skb)) |
| 368 | fcoe_check_wait_queue(lport, skb); |
| 369 | |
| 370 | return 0; |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * bnx2fc_rcv - This is bnx2fc's receive function called by NET_RX_SOFTIRQ |
| 375 | * |
| 376 | * @skb: the receive socket buffer |
| 377 | * @dev: associated net device |
| 378 | * @ptype: context |
| 379 | * @olddev: last device |
| 380 | * |
| 381 | * This function receives the packet and builds FC frame and passes it up |
| 382 | */ |
| 383 | static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev, |
| 384 | struct packet_type *ptype, struct net_device *olddev) |
| 385 | { |
| 386 | struct fc_lport *lport; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 387 | struct bnx2fc_interface *interface; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 388 | struct fc_frame_header *fh; |
| 389 | struct fcoe_rcv_info *fr; |
| 390 | struct fcoe_percpu_s *bg; |
| 391 | unsigned short oxid; |
| 392 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 393 | interface = container_of(ptype, struct bnx2fc_interface, |
| 394 | fcoe_packet_type); |
| 395 | lport = interface->ctlr.lp; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 396 | |
| 397 | if (unlikely(lport == NULL)) { |
Bhanu Prakash Gollapudi | b2a554f | 2011-06-27 23:30:53 -0700 | [diff] [blame] | 398 | printk(KERN_ERR PFX "bnx2fc_rcv: lport is NULL\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 399 | goto err; |
| 400 | } |
| 401 | |
| 402 | if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) { |
Bhanu Prakash Gollapudi | b2a554f | 2011-06-27 23:30:53 -0700 | [diff] [blame] | 403 | printk(KERN_ERR PFX "bnx2fc_rcv: Wrong FC type frame\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 404 | goto err; |
| 405 | } |
| 406 | |
| 407 | /* |
| 408 | * Check for minimum frame length, and make sure required FCoE |
| 409 | * and FC headers are pulled into the linear data area. |
| 410 | */ |
| 411 | if (unlikely((skb->len < FCOE_MIN_FRAME) || |
| 412 | !pskb_may_pull(skb, FCOE_HEADER_LEN))) |
| 413 | goto err; |
| 414 | |
| 415 | skb_set_transport_header(skb, sizeof(struct fcoe_hdr)); |
| 416 | fh = (struct fc_frame_header *) skb_transport_header(skb); |
| 417 | |
| 418 | oxid = ntohs(fh->fh_ox_id); |
| 419 | |
| 420 | fr = fcoe_dev_from_skb(skb); |
| 421 | fr->fr_dev = lport; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 422 | |
| 423 | bg = &bnx2fc_global; |
| 424 | spin_lock_bh(&bg->fcoe_rx_list.lock); |
| 425 | |
| 426 | __skb_queue_tail(&bg->fcoe_rx_list, skb); |
| 427 | if (bg->fcoe_rx_list.qlen == 1) |
| 428 | wake_up_process(bg->thread); |
| 429 | |
| 430 | spin_unlock_bh(&bg->fcoe_rx_list.lock); |
| 431 | |
| 432 | return 0; |
| 433 | err: |
| 434 | kfree_skb(skb); |
| 435 | return -1; |
| 436 | } |
| 437 | |
| 438 | static int bnx2fc_l2_rcv_thread(void *arg) |
| 439 | { |
| 440 | struct fcoe_percpu_s *bg = arg; |
| 441 | struct sk_buff *skb; |
| 442 | |
| 443 | set_user_nice(current, -20); |
| 444 | set_current_state(TASK_INTERRUPTIBLE); |
| 445 | while (!kthread_should_stop()) { |
| 446 | schedule(); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 447 | spin_lock_bh(&bg->fcoe_rx_list.lock); |
| 448 | while ((skb = __skb_dequeue(&bg->fcoe_rx_list)) != NULL) { |
| 449 | spin_unlock_bh(&bg->fcoe_rx_list.lock); |
| 450 | bnx2fc_recv_frame(skb); |
| 451 | spin_lock_bh(&bg->fcoe_rx_list.lock); |
| 452 | } |
Bhanu Gollapudi | fee7871 | 2011-03-21 18:51:13 -0700 | [diff] [blame] | 453 | __set_current_state(TASK_INTERRUPTIBLE); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 454 | spin_unlock_bh(&bg->fcoe_rx_list.lock); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 455 | } |
Bhanu Gollapudi | fee7871 | 2011-03-21 18:51:13 -0700 | [diff] [blame] | 456 | __set_current_state(TASK_RUNNING); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 457 | return 0; |
| 458 | } |
| 459 | |
| 460 | |
| 461 | static void bnx2fc_recv_frame(struct sk_buff *skb) |
| 462 | { |
| 463 | u32 fr_len; |
| 464 | struct fc_lport *lport; |
| 465 | struct fcoe_rcv_info *fr; |
| 466 | struct fcoe_dev_stats *stats; |
| 467 | struct fc_frame_header *fh; |
| 468 | struct fcoe_crc_eof crc_eof; |
| 469 | struct fc_frame *fp; |
| 470 | struct fc_lport *vn_port; |
| 471 | struct fcoe_port *port; |
| 472 | u8 *mac = NULL; |
| 473 | u8 *dest_mac = NULL; |
| 474 | struct fcoe_hdr *hp; |
| 475 | |
| 476 | fr = fcoe_dev_from_skb(skb); |
| 477 | lport = fr->fr_dev; |
| 478 | if (unlikely(lport == NULL)) { |
Bhanu Prakash Gollapudi | b2a554f | 2011-06-27 23:30:53 -0700 | [diff] [blame] | 479 | printk(KERN_ERR PFX "Invalid lport struct\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 480 | kfree_skb(skb); |
| 481 | return; |
| 482 | } |
| 483 | |
| 484 | if (skb_is_nonlinear(skb)) |
| 485 | skb_linearize(skb); |
| 486 | mac = eth_hdr(skb)->h_source; |
| 487 | dest_mac = eth_hdr(skb)->h_dest; |
| 488 | |
| 489 | /* Pull the header */ |
| 490 | hp = (struct fcoe_hdr *) skb_network_header(skb); |
| 491 | fh = (struct fc_frame_header *) skb_transport_header(skb); |
| 492 | skb_pull(skb, sizeof(struct fcoe_hdr)); |
| 493 | fr_len = skb->len - sizeof(struct fcoe_crc_eof); |
| 494 | |
| 495 | stats = per_cpu_ptr(lport->dev_stats, get_cpu()); |
| 496 | stats->RxFrames++; |
| 497 | stats->RxWords += fr_len / FCOE_WORD_TO_BYTE; |
| 498 | |
| 499 | fp = (struct fc_frame *)skb; |
| 500 | fc_frame_init(fp); |
| 501 | fr_dev(fp) = lport; |
| 502 | fr_sof(fp) = hp->fcoe_sof; |
| 503 | if (skb_copy_bits(skb, fr_len, &crc_eof, sizeof(crc_eof))) { |
| 504 | put_cpu(); |
| 505 | kfree_skb(skb); |
| 506 | return; |
| 507 | } |
| 508 | fr_eof(fp) = crc_eof.fcoe_eof; |
| 509 | fr_crc(fp) = crc_eof.fcoe_crc32; |
| 510 | if (pskb_trim(skb, fr_len)) { |
| 511 | put_cpu(); |
| 512 | kfree_skb(skb); |
| 513 | return; |
| 514 | } |
| 515 | |
| 516 | fh = fc_frame_header_get(fp); |
| 517 | |
| 518 | vn_port = fc_vport_id_lookup(lport, ntoh24(fh->fh_d_id)); |
| 519 | if (vn_port) { |
| 520 | port = lport_priv(vn_port); |
| 521 | if (compare_ether_addr(port->data_src_addr, dest_mac) |
| 522 | != 0) { |
| 523 | BNX2FC_HBA_DBG(lport, "fpma mismatch\n"); |
| 524 | put_cpu(); |
| 525 | kfree_skb(skb); |
| 526 | return; |
| 527 | } |
| 528 | } |
| 529 | if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA && |
| 530 | fh->fh_type == FC_TYPE_FCP) { |
| 531 | /* Drop FCP data. We dont this in L2 path */ |
| 532 | put_cpu(); |
| 533 | kfree_skb(skb); |
| 534 | return; |
| 535 | } |
| 536 | if (fh->fh_r_ctl == FC_RCTL_ELS_REQ && |
| 537 | fh->fh_type == FC_TYPE_ELS) { |
| 538 | switch (fc_frame_payload_op(fp)) { |
| 539 | case ELS_LOGO: |
| 540 | if (ntoh24(fh->fh_s_id) == FC_FID_FLOGI) { |
| 541 | /* drop non-FIP LOGO */ |
| 542 | put_cpu(); |
| 543 | kfree_skb(skb); |
| 544 | return; |
| 545 | } |
| 546 | break; |
| 547 | } |
| 548 | } |
Bhanu Prakash Gollapudi | 3f8744d | 2011-08-04 17:38:48 -0700 | [diff] [blame] | 549 | |
| 550 | if (fh->fh_r_ctl == FC_RCTL_BA_ABTS) { |
| 551 | /* Drop incoming ABTS */ |
| 552 | put_cpu(); |
| 553 | kfree_skb(skb); |
| 554 | return; |
| 555 | } |
| 556 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 557 | if (le32_to_cpu(fr_crc(fp)) != |
| 558 | ~crc32(~0, skb->data, fr_len)) { |
| 559 | if (stats->InvalidCRCCount < 5) |
| 560 | printk(KERN_WARNING PFX "dropping frame with " |
| 561 | "CRC error\n"); |
| 562 | stats->InvalidCRCCount++; |
| 563 | put_cpu(); |
| 564 | kfree_skb(skb); |
| 565 | return; |
| 566 | } |
| 567 | put_cpu(); |
| 568 | fc_exch_recv(lport, fp); |
| 569 | } |
| 570 | |
| 571 | /** |
| 572 | * bnx2fc_percpu_io_thread - thread per cpu for ios |
| 573 | * |
| 574 | * @arg: ptr to bnx2fc_percpu_info structure |
| 575 | */ |
| 576 | int bnx2fc_percpu_io_thread(void *arg) |
| 577 | { |
| 578 | struct bnx2fc_percpu_s *p = arg; |
| 579 | struct bnx2fc_work *work, *tmp; |
| 580 | LIST_HEAD(work_list); |
| 581 | |
| 582 | set_user_nice(current, -20); |
| 583 | set_current_state(TASK_INTERRUPTIBLE); |
| 584 | while (!kthread_should_stop()) { |
| 585 | schedule(); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 586 | spin_lock_bh(&p->fp_work_lock); |
| 587 | while (!list_empty(&p->work_list)) { |
| 588 | list_splice_init(&p->work_list, &work_list); |
| 589 | spin_unlock_bh(&p->fp_work_lock); |
| 590 | |
| 591 | list_for_each_entry_safe(work, tmp, &work_list, list) { |
| 592 | list_del_init(&work->list); |
| 593 | bnx2fc_process_cq_compl(work->tgt, work->wqe); |
| 594 | kfree(work); |
| 595 | } |
| 596 | |
| 597 | spin_lock_bh(&p->fp_work_lock); |
| 598 | } |
Bhanu Gollapudi | fee7871 | 2011-03-21 18:51:13 -0700 | [diff] [blame] | 599 | __set_current_state(TASK_INTERRUPTIBLE); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 600 | spin_unlock_bh(&p->fp_work_lock); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 601 | } |
Bhanu Gollapudi | fee7871 | 2011-03-21 18:51:13 -0700 | [diff] [blame] | 602 | __set_current_state(TASK_RUNNING); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 603 | |
| 604 | return 0; |
| 605 | } |
| 606 | |
| 607 | static struct fc_host_statistics *bnx2fc_get_host_stats(struct Scsi_Host *shost) |
| 608 | { |
| 609 | struct fc_host_statistics *bnx2fc_stats; |
| 610 | struct fc_lport *lport = shost_priv(shost); |
| 611 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 612 | struct bnx2fc_interface *interface = port->priv; |
| 613 | struct bnx2fc_hba *hba = interface->hba; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 614 | struct fcoe_statistics_params *fw_stats; |
| 615 | int rc = 0; |
| 616 | |
| 617 | fw_stats = (struct fcoe_statistics_params *)hba->stats_buffer; |
| 618 | if (!fw_stats) |
| 619 | return NULL; |
| 620 | |
| 621 | bnx2fc_stats = fc_get_host_stats(shost); |
| 622 | |
| 623 | init_completion(&hba->stat_req_done); |
| 624 | if (bnx2fc_send_stat_req(hba)) |
| 625 | return bnx2fc_stats; |
| 626 | rc = wait_for_completion_timeout(&hba->stat_req_done, (2 * HZ)); |
| 627 | if (!rc) { |
| 628 | BNX2FC_HBA_DBG(lport, "FW stat req timed out\n"); |
| 629 | return bnx2fc_stats; |
| 630 | } |
Vlad Zolotarov | 619c5cb | 2011-06-14 14:33:44 +0300 | [diff] [blame] | 631 | bnx2fc_stats->invalid_crc_count += fw_stats->rx_stat2.fc_crc_cnt; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 632 | bnx2fc_stats->tx_frames += fw_stats->tx_stat.fcoe_tx_pkt_cnt; |
| 633 | bnx2fc_stats->tx_words += (fw_stats->tx_stat.fcoe_tx_byte_cnt) / 4; |
| 634 | bnx2fc_stats->rx_frames += fw_stats->rx_stat0.fcoe_rx_pkt_cnt; |
| 635 | bnx2fc_stats->rx_words += (fw_stats->rx_stat0.fcoe_rx_byte_cnt) / 4; |
| 636 | |
| 637 | bnx2fc_stats->dumped_frames = 0; |
| 638 | bnx2fc_stats->lip_count = 0; |
| 639 | bnx2fc_stats->nos_count = 0; |
| 640 | bnx2fc_stats->loss_of_sync_count = 0; |
| 641 | bnx2fc_stats->loss_of_signal_count = 0; |
| 642 | bnx2fc_stats->prim_seq_protocol_err_count = 0; |
| 643 | |
| 644 | return bnx2fc_stats; |
| 645 | } |
| 646 | |
| 647 | static int bnx2fc_shost_config(struct fc_lport *lport, struct device *dev) |
| 648 | { |
| 649 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 650 | struct bnx2fc_interface *interface = port->priv; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 651 | struct Scsi_Host *shost = lport->host; |
| 652 | int rc = 0; |
| 653 | |
| 654 | shost->max_cmd_len = BNX2FC_MAX_CMD_LEN; |
| 655 | shost->max_lun = BNX2FC_MAX_LUN; |
| 656 | shost->max_id = BNX2FC_MAX_FCP_TGT; |
| 657 | shost->max_channel = 0; |
| 658 | if (lport->vport) |
| 659 | shost->transportt = bnx2fc_vport_xport_template; |
| 660 | else |
| 661 | shost->transportt = bnx2fc_transport_template; |
| 662 | |
| 663 | /* Add the new host to SCSI-ml */ |
| 664 | rc = scsi_add_host(lport->host, dev); |
| 665 | if (rc) { |
| 666 | printk(KERN_ERR PFX "Error on scsi_add_host\n"); |
| 667 | return rc; |
| 668 | } |
| 669 | if (!lport->vport) |
| 670 | fc_host_max_npiv_vports(lport->host) = USHRT_MAX; |
| 671 | sprintf(fc_host_symbolic_name(lport->host), "%s v%s over %s", |
| 672 | BNX2FC_NAME, BNX2FC_VERSION, |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 673 | interface->netdev->name); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 674 | |
| 675 | return 0; |
| 676 | } |
| 677 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 678 | static void bnx2fc_link_speed_update(struct fc_lport *lport) |
| 679 | { |
| 680 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 681 | struct bnx2fc_interface *interface = port->priv; |
| 682 | struct net_device *netdev = interface->netdev; |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 683 | struct ethtool_cmd ecmd; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 684 | |
| 685 | if (!dev_ethtool_get_settings(netdev, &ecmd)) { |
| 686 | lport->link_supported_speeds &= |
| 687 | ~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT); |
| 688 | if (ecmd.supported & (SUPPORTED_1000baseT_Half | |
| 689 | SUPPORTED_1000baseT_Full)) |
| 690 | lport->link_supported_speeds |= FC_PORTSPEED_1GBIT; |
| 691 | if (ecmd.supported & SUPPORTED_10000baseT_Full) |
| 692 | lport->link_supported_speeds |= FC_PORTSPEED_10GBIT; |
| 693 | |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 694 | switch (ethtool_cmd_speed(&ecmd)) { |
| 695 | case SPEED_1000: |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 696 | lport->link_speed = FC_PORTSPEED_1GBIT; |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 697 | break; |
Bhanu Prakash Gollapudi | a4dc08c | 2011-05-27 11:47:25 -0700 | [diff] [blame] | 698 | case SPEED_2500: |
| 699 | lport->link_speed = FC_PORTSPEED_2GBIT; |
| 700 | break; |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 701 | case SPEED_10000: |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 702 | lport->link_speed = FC_PORTSPEED_10GBIT; |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 703 | break; |
| 704 | } |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 705 | } |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 706 | } |
| 707 | static int bnx2fc_link_ok(struct fc_lport *lport) |
| 708 | { |
| 709 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 710 | struct bnx2fc_interface *interface = port->priv; |
| 711 | struct bnx2fc_hba *hba = interface->hba; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 712 | struct net_device *dev = hba->phys_dev; |
| 713 | int rc = 0; |
| 714 | |
| 715 | if ((dev->flags & IFF_UP) && netif_carrier_ok(dev)) |
| 716 | clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); |
| 717 | else { |
| 718 | set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); |
| 719 | rc = -1; |
| 720 | } |
| 721 | return rc; |
| 722 | } |
| 723 | |
| 724 | /** |
| 725 | * bnx2fc_get_link_state - get network link state |
| 726 | * |
| 727 | * @hba: adapter instance pointer |
| 728 | * |
| 729 | * updates adapter structure flag based on netdev state |
| 730 | */ |
| 731 | void bnx2fc_get_link_state(struct bnx2fc_hba *hba) |
| 732 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 733 | if (test_bit(__LINK_STATE_NOCARRIER, &hba->phys_dev->state)) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 734 | set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); |
| 735 | else |
| 736 | clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); |
| 737 | } |
| 738 | |
Bhanu Prakash Gollapudi | 5243960 | 2011-08-04 17:38:50 -0700 | [diff] [blame] | 739 | static int bnx2fc_net_config(struct fc_lport *lport, struct net_device *netdev) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 740 | { |
| 741 | struct bnx2fc_hba *hba; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 742 | struct bnx2fc_interface *interface; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 743 | struct fcoe_port *port; |
| 744 | u64 wwnn, wwpn; |
| 745 | |
| 746 | port = lport_priv(lport); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 747 | interface = port->priv; |
| 748 | hba = interface->hba; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 749 | |
| 750 | /* require support for get_pauseparam ethtool op. */ |
| 751 | if (!hba->phys_dev->ethtool_ops || |
| 752 | !hba->phys_dev->ethtool_ops->get_pauseparam) |
| 753 | return -EOPNOTSUPP; |
| 754 | |
Bhanu Gollapudi | 1294bfe | 2011-03-17 17:13:34 -0700 | [diff] [blame] | 755 | if (fc_set_mfs(lport, BNX2FC_MFS)) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 756 | return -EINVAL; |
| 757 | |
| 758 | skb_queue_head_init(&port->fcoe_pending_queue); |
| 759 | port->fcoe_pending_queue_active = 0; |
| 760 | setup_timer(&port->timer, fcoe_queue_timer, (unsigned long) lport); |
| 761 | |
| 762 | bnx2fc_link_speed_update(lport); |
| 763 | |
| 764 | if (!lport->vport) { |
Bhanu Prakash Gollapudi | 5243960 | 2011-08-04 17:38:50 -0700 | [diff] [blame] | 765 | if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN)) |
| 766 | wwnn = fcoe_wwn_from_mac(interface->ctlr.ctl_src_addr, |
| 767 | 1, 0); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 768 | BNX2FC_HBA_DBG(lport, "WWNN = 0x%llx\n", wwnn); |
| 769 | fc_set_wwnn(lport, wwnn); |
| 770 | |
Bhanu Prakash Gollapudi | 5243960 | 2011-08-04 17:38:50 -0700 | [diff] [blame] | 771 | if (fcoe_get_wwn(netdev, &wwpn, NETDEV_FCOE_WWPN)) |
| 772 | wwpn = fcoe_wwn_from_mac(interface->ctlr.ctl_src_addr, |
| 773 | 2, 0); |
| 774 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 775 | BNX2FC_HBA_DBG(lport, "WWPN = 0x%llx\n", wwpn); |
| 776 | fc_set_wwpn(lport, wwpn); |
| 777 | } |
| 778 | |
| 779 | return 0; |
| 780 | } |
| 781 | |
| 782 | static void bnx2fc_destroy_timer(unsigned long data) |
| 783 | { |
| 784 | struct bnx2fc_hba *hba = (struct bnx2fc_hba *)data; |
| 785 | |
Bhanu Prakash Gollapudi | cd703ae | 2011-08-04 17:38:43 -0700 | [diff] [blame] | 786 | printk(KERN_ERR PFX "ERROR:bnx2fc_destroy_timer - " |
| 787 | "Destroy compl not received!!\n"); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 788 | set_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 789 | wake_up_interruptible(&hba->destroy_wait); |
| 790 | } |
| 791 | |
| 792 | /** |
| 793 | * bnx2fc_indicate_netevent - Generic netdev event handler |
| 794 | * |
| 795 | * @context: adapter structure pointer |
| 796 | * @event: event type |
Michael Chan | 415199f | 2011-07-20 14:55:24 +0000 | [diff] [blame] | 797 | * @vlan_id: vlan id - associated vlan id with this event |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 798 | * |
| 799 | * Handles NETDEV_UP, NETDEV_DOWN, NETDEV_GOING_DOWN,NETDEV_CHANGE and |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 800 | * NETDEV_CHANGE_MTU events. Handle NETDEV_UNREGISTER only for vlans. |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 801 | */ |
Michael Chan | 415199f | 2011-07-20 14:55:24 +0000 | [diff] [blame] | 802 | static void bnx2fc_indicate_netevent(void *context, unsigned long event, |
| 803 | u16 vlan_id) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 804 | { |
| 805 | struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 806 | struct fc_lport *lport; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 807 | struct fc_lport *vport; |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 808 | struct bnx2fc_interface *interface, *tmp; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 809 | int wait_for_upload = 0; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 810 | u32 link_possible = 1; |
| 811 | |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 812 | if (vlan_id != 0 && event != NETDEV_UNREGISTER) |
Michael Chan | 415199f | 2011-07-20 14:55:24 +0000 | [diff] [blame] | 813 | return; |
| 814 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 815 | switch (event) { |
| 816 | case NETDEV_UP: |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 817 | if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) |
| 818 | printk(KERN_ERR "indicate_netevent: "\ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 819 | "hba is not UP!!\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 820 | break; |
| 821 | |
| 822 | case NETDEV_DOWN: |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 823 | clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); |
| 824 | clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); |
| 825 | link_possible = 0; |
| 826 | break; |
| 827 | |
| 828 | case NETDEV_GOING_DOWN: |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 829 | set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); |
| 830 | link_possible = 0; |
| 831 | break; |
| 832 | |
| 833 | case NETDEV_CHANGE: |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 834 | break; |
| 835 | |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 836 | case NETDEV_UNREGISTER: |
| 837 | if (!vlan_id) |
| 838 | return; |
| 839 | mutex_lock(&bnx2fc_dev_lock); |
| 840 | list_for_each_entry_safe(interface, tmp, &if_list, list) { |
| 841 | if (interface->hba != hba) |
| 842 | continue; |
Bhanu Prakash Gollapudi | eccdcd0 | 2011-08-24 18:56:42 -0700 | [diff] [blame^] | 843 | __bnx2fc_destroy(interface); |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 844 | } |
| 845 | mutex_unlock(&bnx2fc_dev_lock); |
| 846 | return; |
| 847 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 848 | default: |
| 849 | printk(KERN_ERR PFX "Unkonwn netevent %ld", event); |
| 850 | return; |
| 851 | } |
| 852 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 853 | mutex_lock(&bnx2fc_dev_lock); |
| 854 | list_for_each_entry(interface, &if_list, list) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 855 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 856 | if (interface->hba != hba) |
| 857 | continue; |
| 858 | |
| 859 | lport = interface->ctlr.lp; |
| 860 | BNX2FC_HBA_DBG(lport, "netevent handler - event=%s %ld\n", |
| 861 | interface->netdev->name, event); |
| 862 | |
| 863 | bnx2fc_link_speed_update(lport); |
| 864 | |
| 865 | if (link_possible && !bnx2fc_link_ok(lport)) { |
| 866 | printk(KERN_ERR "indicate_netevent: ctlr_link_up\n"); |
| 867 | fcoe_ctlr_link_up(&interface->ctlr); |
| 868 | } else if (fcoe_ctlr_link_down(&interface->ctlr)) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 869 | mutex_lock(&lport->lp_mutex); |
| 870 | list_for_each_entry(vport, &lport->vports, list) |
| 871 | fc_host_port_type(vport->host) = |
| 872 | FC_PORTTYPE_UNKNOWN; |
| 873 | mutex_unlock(&lport->lp_mutex); |
| 874 | fc_host_port_type(lport->host) = FC_PORTTYPE_UNKNOWN; |
| 875 | per_cpu_ptr(lport->dev_stats, |
| 876 | get_cpu())->LinkFailureCount++; |
| 877 | put_cpu(); |
| 878 | fcoe_clean_pending_queue(lport); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 879 | wait_for_upload = 1; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 880 | } |
| 881 | } |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 882 | mutex_unlock(&bnx2fc_dev_lock); |
| 883 | |
| 884 | if (wait_for_upload) { |
| 885 | clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); |
| 886 | init_waitqueue_head(&hba->shutdown_wait); |
| 887 | BNX2FC_MISC_DBG("indicate_netevent " |
| 888 | "num_ofld_sess = %d\n", |
| 889 | hba->num_ofld_sess); |
| 890 | hba->wait_for_link_down = 1; |
| 891 | wait_event_interruptible(hba->shutdown_wait, |
| 892 | (hba->num_ofld_sess == 0)); |
| 893 | BNX2FC_MISC_DBG("wakeup - num_ofld_sess = %d\n", |
| 894 | hba->num_ofld_sess); |
| 895 | hba->wait_for_link_down = 0; |
| 896 | |
| 897 | if (signal_pending(current)) |
| 898 | flush_signals(current); |
| 899 | } |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | static int bnx2fc_libfc_config(struct fc_lport *lport) |
| 903 | { |
| 904 | |
| 905 | /* Set the function pointers set by bnx2fc driver */ |
| 906 | memcpy(&lport->tt, &bnx2fc_libfc_fcn_templ, |
| 907 | sizeof(struct libfc_function_template)); |
| 908 | fc_elsct_init(lport); |
| 909 | fc_exch_init(lport); |
| 910 | fc_rport_init(lport); |
| 911 | fc_disc_init(lport); |
| 912 | return 0; |
| 913 | } |
| 914 | |
| 915 | static int bnx2fc_em_config(struct fc_lport *lport) |
| 916 | { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 917 | if (!fc_exch_mgr_alloc(lport, FC_CLASS_3, FCOE_MIN_XID, |
| 918 | FCOE_MAX_XID, NULL)) { |
| 919 | printk(KERN_ERR PFX "em_config:fc_exch_mgr_alloc failed\n"); |
| 920 | return -ENOMEM; |
| 921 | } |
| 922 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 923 | return 0; |
| 924 | } |
| 925 | |
| 926 | static int bnx2fc_lport_config(struct fc_lport *lport) |
| 927 | { |
| 928 | lport->link_up = 0; |
| 929 | lport->qfull = 0; |
| 930 | lport->max_retry_count = 3; |
| 931 | lport->max_rport_retry_count = 3; |
| 932 | lport->e_d_tov = 2 * 1000; |
| 933 | lport->r_a_tov = 10 * 1000; |
| 934 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 935 | lport->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS | |
| 936 | FCP_SPPF_RETRY | FCP_SPPF_CONF_COMPL); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 937 | lport->does_npiv = 1; |
| 938 | |
| 939 | memset(&lport->rnid_gen, 0, sizeof(struct fc_els_rnid_gen)); |
| 940 | lport->rnid_gen.rnid_atype = BNX2FC_RNID_HBA; |
| 941 | |
| 942 | /* alloc stats structure */ |
| 943 | if (fc_lport_init_stats(lport)) |
| 944 | return -ENOMEM; |
| 945 | |
| 946 | /* Finish fc_lport configuration */ |
| 947 | fc_lport_config(lport); |
| 948 | |
| 949 | return 0; |
| 950 | } |
| 951 | |
| 952 | /** |
| 953 | * bnx2fc_fip_recv - handle a received FIP frame. |
| 954 | * |
| 955 | * @skb: the received skb |
| 956 | * @dev: associated &net_device |
| 957 | * @ptype: the &packet_type structure which was used to register this handler. |
| 958 | * @orig_dev: original receive &net_device, in case @ dev is a bond. |
| 959 | * |
| 960 | * Returns: 0 for success |
| 961 | */ |
| 962 | static int bnx2fc_fip_recv(struct sk_buff *skb, struct net_device *dev, |
| 963 | struct packet_type *ptype, |
| 964 | struct net_device *orig_dev) |
| 965 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 966 | struct bnx2fc_interface *interface; |
| 967 | interface = container_of(ptype, struct bnx2fc_interface, |
| 968 | fip_packet_type); |
| 969 | fcoe_ctlr_recv(&interface->ctlr, skb); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 970 | return 0; |
| 971 | } |
| 972 | |
| 973 | /** |
| 974 | * bnx2fc_update_src_mac - Update Ethernet MAC filters. |
| 975 | * |
| 976 | * @fip: FCoE controller. |
| 977 | * @old: Unicast MAC address to delete if the MAC is non-zero. |
| 978 | * @new: Unicast MAC address to add. |
| 979 | * |
| 980 | * Remove any previously-set unicast MAC filter. |
| 981 | * Add secondary FCoE MAC address filter for our OUI. |
| 982 | */ |
| 983 | static void bnx2fc_update_src_mac(struct fc_lport *lport, u8 *addr) |
| 984 | { |
| 985 | struct fcoe_port *port = lport_priv(lport); |
| 986 | |
| 987 | memcpy(port->data_src_addr, addr, ETH_ALEN); |
| 988 | } |
| 989 | |
| 990 | /** |
| 991 | * bnx2fc_get_src_mac - return the ethernet source address for an lport |
| 992 | * |
| 993 | * @lport: libfc port |
| 994 | */ |
| 995 | static u8 *bnx2fc_get_src_mac(struct fc_lport *lport) |
| 996 | { |
| 997 | struct fcoe_port *port; |
| 998 | |
| 999 | port = (struct fcoe_port *)lport_priv(lport); |
| 1000 | return port->data_src_addr; |
| 1001 | } |
| 1002 | |
| 1003 | /** |
| 1004 | * bnx2fc_fip_send - send an Ethernet-encapsulated FIP frame. |
| 1005 | * |
| 1006 | * @fip: FCoE controller. |
| 1007 | * @skb: FIP Packet. |
| 1008 | */ |
| 1009 | static void bnx2fc_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb) |
| 1010 | { |
| 1011 | skb->dev = bnx2fc_from_ctlr(fip)->netdev; |
| 1012 | dev_queue_xmit(skb); |
| 1013 | } |
| 1014 | |
| 1015 | static int bnx2fc_vport_create(struct fc_vport *vport, bool disabled) |
| 1016 | { |
| 1017 | struct Scsi_Host *shost = vport_to_shost(vport); |
| 1018 | struct fc_lport *n_port = shost_priv(shost); |
| 1019 | struct fcoe_port *port = lport_priv(n_port); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1020 | struct bnx2fc_interface *interface = port->priv; |
| 1021 | struct net_device *netdev = interface->netdev; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1022 | struct fc_lport *vn_port; |
Bhanu Prakash Gollapudi | 861efc5 | 2011-08-04 17:38:51 -0700 | [diff] [blame] | 1023 | int rc; |
| 1024 | char buf[32]; |
| 1025 | |
| 1026 | rc = fcoe_validate_vport_create(vport); |
| 1027 | if (rc) { |
| 1028 | fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf)); |
| 1029 | printk(KERN_ERR PFX "Failed to create vport, " |
| 1030 | "WWPN (0x%s) already exists\n", |
| 1031 | buf); |
| 1032 | return rc; |
| 1033 | } |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1034 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1035 | if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1036 | printk(KERN_ERR PFX "vn ports cannot be created on" |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1037 | "this interface\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1038 | return -EIO; |
| 1039 | } |
| 1040 | mutex_lock(&bnx2fc_dev_lock); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1041 | vn_port = bnx2fc_if_create(interface, &vport->dev, 1); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1042 | mutex_unlock(&bnx2fc_dev_lock); |
| 1043 | |
| 1044 | if (IS_ERR(vn_port)) { |
| 1045 | printk(KERN_ERR PFX "bnx2fc_vport_create (%s) failed\n", |
| 1046 | netdev->name); |
| 1047 | return -EIO; |
| 1048 | } |
| 1049 | |
| 1050 | if (disabled) { |
| 1051 | fc_vport_set_state(vport, FC_VPORT_DISABLED); |
| 1052 | } else { |
| 1053 | vn_port->boot_time = jiffies; |
| 1054 | fc_lport_init(vn_port); |
| 1055 | fc_fabric_login(vn_port); |
| 1056 | fc_vport_setlink(vn_port); |
| 1057 | } |
| 1058 | return 0; |
| 1059 | } |
| 1060 | |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 1061 | static void bnx2fc_free_vport(struct bnx2fc_hba *hba, struct fc_lport *lport) |
| 1062 | { |
| 1063 | struct bnx2fc_lport *blport, *tmp; |
| 1064 | |
| 1065 | spin_lock_bh(&hba->hba_lock); |
| 1066 | list_for_each_entry_safe(blport, tmp, &hba->vports, list) { |
| 1067 | if (blport->lport == lport) { |
| 1068 | list_del(&blport->list); |
| 1069 | kfree(blport); |
| 1070 | } |
| 1071 | } |
| 1072 | spin_unlock_bh(&hba->hba_lock); |
| 1073 | } |
| 1074 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1075 | static int bnx2fc_vport_destroy(struct fc_vport *vport) |
| 1076 | { |
| 1077 | struct Scsi_Host *shost = vport_to_shost(vport); |
| 1078 | struct fc_lport *n_port = shost_priv(shost); |
| 1079 | struct fc_lport *vn_port = vport->dd_data; |
| 1080 | struct fcoe_port *port = lport_priv(vn_port); |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 1081 | struct bnx2fc_interface *interface = port->priv; |
Bhanu Prakash Gollapudi | cdf5466 | 2011-08-04 17:38:39 -0700 | [diff] [blame] | 1082 | struct fc_lport *v_port; |
| 1083 | bool found = false; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1084 | |
| 1085 | mutex_lock(&n_port->lp_mutex); |
Bhanu Prakash Gollapudi | cdf5466 | 2011-08-04 17:38:39 -0700 | [diff] [blame] | 1086 | list_for_each_entry(v_port, &n_port->vports, list) |
| 1087 | if (v_port->vport == vport) { |
| 1088 | found = true; |
| 1089 | break; |
| 1090 | } |
| 1091 | |
| 1092 | if (!found) { |
| 1093 | mutex_unlock(&n_port->lp_mutex); |
| 1094 | return -ENOENT; |
| 1095 | } |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1096 | list_del(&vn_port->list); |
| 1097 | mutex_unlock(&n_port->lp_mutex); |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 1098 | bnx2fc_free_vport(interface->hba, port->lport); |
| 1099 | bnx2fc_port_shutdown(port->lport); |
| 1100 | bnx2fc_interface_put(interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1101 | queue_work(bnx2fc_wq, &port->destroy_work); |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
| 1105 | static int bnx2fc_vport_disable(struct fc_vport *vport, bool disable) |
| 1106 | { |
| 1107 | struct fc_lport *lport = vport->dd_data; |
| 1108 | |
| 1109 | if (disable) { |
| 1110 | fc_vport_set_state(vport, FC_VPORT_DISABLED); |
| 1111 | fc_fabric_logoff(lport); |
| 1112 | } else { |
| 1113 | lport->boot_time = jiffies; |
| 1114 | fc_fabric_login(lport); |
| 1115 | fc_vport_setlink(lport); |
| 1116 | } |
| 1117 | return 0; |
| 1118 | } |
| 1119 | |
| 1120 | |
Bhanu Prakash Gollapudi | 776cebc | 2011-08-04 17:38:40 -0700 | [diff] [blame] | 1121 | static int bnx2fc_interface_setup(struct bnx2fc_interface *interface) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1122 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1123 | struct net_device *netdev = interface->netdev; |
| 1124 | struct net_device *physdev = interface->hba->phys_dev; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1125 | struct netdev_hw_addr *ha; |
| 1126 | int sel_san_mac = 0; |
| 1127 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1128 | /* setup Source MAC Address */ |
| 1129 | rcu_read_lock(); |
| 1130 | for_each_dev_addr(physdev, ha) { |
| 1131 | BNX2FC_MISC_DBG("net_config: ha->type = %d, fip_mac = ", |
| 1132 | ha->type); |
| 1133 | printk(KERN_INFO "%2x:%2x:%2x:%2x:%2x:%2x\n", ha->addr[0], |
| 1134 | ha->addr[1], ha->addr[2], ha->addr[3], |
| 1135 | ha->addr[4], ha->addr[5]); |
| 1136 | |
| 1137 | if ((ha->type == NETDEV_HW_ADDR_T_SAN) && |
| 1138 | (is_valid_ether_addr(ha->addr))) { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1139 | memcpy(interface->ctlr.ctl_src_addr, ha->addr, |
| 1140 | ETH_ALEN); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1141 | sel_san_mac = 1; |
| 1142 | BNX2FC_MISC_DBG("Found SAN MAC\n"); |
| 1143 | } |
| 1144 | } |
| 1145 | rcu_read_unlock(); |
| 1146 | |
| 1147 | if (!sel_san_mac) |
| 1148 | return -ENODEV; |
| 1149 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1150 | interface->fip_packet_type.func = bnx2fc_fip_recv; |
| 1151 | interface->fip_packet_type.type = htons(ETH_P_FIP); |
| 1152 | interface->fip_packet_type.dev = netdev; |
| 1153 | dev_add_pack(&interface->fip_packet_type); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1154 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1155 | interface->fcoe_packet_type.func = bnx2fc_rcv; |
| 1156 | interface->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE); |
| 1157 | interface->fcoe_packet_type.dev = netdev; |
| 1158 | dev_add_pack(&interface->fcoe_packet_type); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1159 | |
| 1160 | return 0; |
| 1161 | } |
| 1162 | |
| 1163 | static int bnx2fc_attach_transport(void) |
| 1164 | { |
| 1165 | bnx2fc_transport_template = |
| 1166 | fc_attach_transport(&bnx2fc_transport_function); |
| 1167 | |
| 1168 | if (bnx2fc_transport_template == NULL) { |
| 1169 | printk(KERN_ERR PFX "Failed to attach FC transport\n"); |
| 1170 | return -ENODEV; |
| 1171 | } |
| 1172 | |
| 1173 | bnx2fc_vport_xport_template = |
| 1174 | fc_attach_transport(&bnx2fc_vport_xport_function); |
| 1175 | if (bnx2fc_vport_xport_template == NULL) { |
| 1176 | printk(KERN_ERR PFX |
| 1177 | "Failed to attach FC transport for vport\n"); |
| 1178 | fc_release_transport(bnx2fc_transport_template); |
| 1179 | bnx2fc_transport_template = NULL; |
| 1180 | return -ENODEV; |
| 1181 | } |
| 1182 | return 0; |
| 1183 | } |
| 1184 | static void bnx2fc_release_transport(void) |
| 1185 | { |
| 1186 | fc_release_transport(bnx2fc_transport_template); |
| 1187 | fc_release_transport(bnx2fc_vport_xport_template); |
| 1188 | bnx2fc_transport_template = NULL; |
| 1189 | bnx2fc_vport_xport_template = NULL; |
| 1190 | } |
| 1191 | |
| 1192 | static void bnx2fc_interface_release(struct kref *kref) |
| 1193 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1194 | struct bnx2fc_interface *interface; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1195 | struct net_device *netdev; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1196 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1197 | interface = container_of(kref, struct bnx2fc_interface, kref); |
Nithin Nayak Sujir | 068bdce | 2011-04-25 12:30:09 -0700 | [diff] [blame] | 1198 | BNX2FC_MISC_DBG("Interface is being released\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1199 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1200 | netdev = interface->netdev; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1201 | |
| 1202 | /* tear-down FIP controller */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1203 | if (test_and_clear_bit(BNX2FC_CTLR_INIT_DONE, &interface->if_flags)) |
| 1204 | fcoe_ctlr_destroy(&interface->ctlr); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1205 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1206 | kfree(interface); |
| 1207 | |
| 1208 | dev_put(netdev); |
| 1209 | module_put(THIS_MODULE); |
| 1210 | } |
| 1211 | |
| 1212 | static inline void bnx2fc_interface_get(struct bnx2fc_interface *interface) |
| 1213 | { |
| 1214 | kref_get(&interface->kref); |
| 1215 | } |
| 1216 | |
| 1217 | static inline void bnx2fc_interface_put(struct bnx2fc_interface *interface) |
| 1218 | { |
| 1219 | kref_put(&interface->kref, bnx2fc_interface_release); |
| 1220 | } |
| 1221 | static void bnx2fc_hba_destroy(struct bnx2fc_hba *hba) |
| 1222 | { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1223 | /* Free the command manager */ |
| 1224 | if (hba->cmd_mgr) { |
| 1225 | bnx2fc_cmd_mgr_free(hba->cmd_mgr); |
| 1226 | hba->cmd_mgr = NULL; |
| 1227 | } |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1228 | kfree(hba->tgt_ofld_list); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1229 | bnx2fc_unbind_pcidev(hba); |
| 1230 | kfree(hba); |
| 1231 | } |
| 1232 | |
| 1233 | /** |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1234 | * bnx2fc_hba_create - create a new bnx2fc hba |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1235 | * |
| 1236 | * @cnic: pointer to cnic device |
| 1237 | * |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1238 | * Creates a new FCoE hba on the given device. |
| 1239 | * |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1240 | */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1241 | static struct bnx2fc_hba *bnx2fc_hba_create(struct cnic_dev *cnic) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1242 | { |
| 1243 | struct bnx2fc_hba *hba; |
| 1244 | int rc; |
| 1245 | |
| 1246 | hba = kzalloc(sizeof(*hba), GFP_KERNEL); |
| 1247 | if (!hba) { |
| 1248 | printk(KERN_ERR PFX "Unable to allocate hba structure\n"); |
| 1249 | return NULL; |
| 1250 | } |
| 1251 | spin_lock_init(&hba->hba_lock); |
| 1252 | mutex_init(&hba->hba_mutex); |
| 1253 | |
| 1254 | hba->cnic = cnic; |
| 1255 | rc = bnx2fc_bind_pcidev(hba); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1256 | if (rc) { |
| 1257 | printk(KERN_ERR PFX "create_adapter: bind error\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1258 | goto bind_err; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1259 | } |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1260 | hba->phys_dev = cnic->netdev; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1261 | hba->next_conn_id = 0; |
| 1262 | |
| 1263 | hba->tgt_ofld_list = |
| 1264 | kzalloc(sizeof(struct bnx2fc_rport *) * BNX2FC_NUM_MAX_SESS, |
| 1265 | GFP_KERNEL); |
| 1266 | if (!hba->tgt_ofld_list) { |
| 1267 | printk(KERN_ERR PFX "Unable to allocate tgt offload list\n"); |
| 1268 | goto tgtofld_err; |
| 1269 | } |
| 1270 | |
| 1271 | hba->num_ofld_sess = 0; |
| 1272 | |
| 1273 | hba->cmd_mgr = bnx2fc_cmd_mgr_alloc(hba, BNX2FC_MIN_XID, |
| 1274 | BNX2FC_MAX_XID); |
| 1275 | if (!hba->cmd_mgr) { |
| 1276 | printk(KERN_ERR PFX "em_config:bnx2fc_cmd_mgr_alloc failed\n"); |
| 1277 | goto cmgr_err; |
| 1278 | } |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1279 | |
| 1280 | init_waitqueue_head(&hba->shutdown_wait); |
| 1281 | init_waitqueue_head(&hba->destroy_wait); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1282 | INIT_LIST_HEAD(&hba->vports); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1283 | |
| 1284 | return hba; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1285 | |
| 1286 | cmgr_err: |
| 1287 | kfree(hba->tgt_ofld_list); |
| 1288 | tgtofld_err: |
| 1289 | bnx2fc_unbind_pcidev(hba); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1290 | bind_err: |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1291 | kfree(hba); |
| 1292 | return NULL; |
| 1293 | } |
| 1294 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1295 | struct bnx2fc_interface *bnx2fc_interface_create(struct bnx2fc_hba *hba, |
| 1296 | struct net_device *netdev, |
| 1297 | enum fip_state fip_mode) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1298 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1299 | struct bnx2fc_interface *interface; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1300 | int rc = 0; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1301 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1302 | interface = kzalloc(sizeof(*interface), GFP_KERNEL); |
| 1303 | if (!interface) { |
| 1304 | printk(KERN_ERR PFX "Unable to allocate interface structure\n"); |
| 1305 | return NULL; |
| 1306 | } |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1307 | dev_hold(netdev); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1308 | kref_init(&interface->kref); |
| 1309 | interface->hba = hba; |
| 1310 | interface->netdev = netdev; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1311 | |
| 1312 | /* Initialize FIP */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1313 | fcoe_ctlr_init(&interface->ctlr, fip_mode); |
| 1314 | interface->ctlr.send = bnx2fc_fip_send; |
| 1315 | interface->ctlr.update_mac = bnx2fc_update_src_mac; |
| 1316 | interface->ctlr.get_src_addr = bnx2fc_get_src_mac; |
| 1317 | set_bit(BNX2FC_CTLR_INIT_DONE, &interface->if_flags); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1318 | |
Bhanu Prakash Gollapudi | 776cebc | 2011-08-04 17:38:40 -0700 | [diff] [blame] | 1319 | rc = bnx2fc_interface_setup(interface); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1320 | if (!rc) |
| 1321 | return interface; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1322 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1323 | fcoe_ctlr_destroy(&interface->ctlr); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1324 | dev_put(netdev); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1325 | kfree(interface); |
| 1326 | return NULL; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1327 | } |
| 1328 | |
| 1329 | /** |
| 1330 | * bnx2fc_if_create - Create FCoE instance on a given interface |
| 1331 | * |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1332 | * @interface: FCoE interface to create a local port on |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1333 | * @parent: Device pointer to be the parent in sysfs for the SCSI host |
| 1334 | * @npiv: Indicates if the port is vport or not |
| 1335 | * |
| 1336 | * Creates a fc_lport instance and a Scsi_Host instance and configure them. |
| 1337 | * |
| 1338 | * Returns: Allocated fc_lport or an error pointer |
| 1339 | */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1340 | static struct fc_lport *bnx2fc_if_create(struct bnx2fc_interface *interface, |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1341 | struct device *parent, int npiv) |
| 1342 | { |
Vasu Dev | 134a4e2 | 2011-04-28 15:55:44 -0700 | [diff] [blame] | 1343 | struct fc_lport *lport, *n_port; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1344 | struct fcoe_port *port; |
| 1345 | struct Scsi_Host *shost; |
| 1346 | struct fc_vport *vport = dev_to_vport(parent); |
Bhanu Prakash Gollapudi | d36b327 | 2011-05-27 11:47:27 -0700 | [diff] [blame] | 1347 | struct bnx2fc_lport *blport; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1348 | struct bnx2fc_hba *hba; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1349 | int rc = 0; |
| 1350 | |
Bhanu Prakash Gollapudi | d36b327 | 2011-05-27 11:47:27 -0700 | [diff] [blame] | 1351 | blport = kzalloc(sizeof(struct bnx2fc_lport), GFP_KERNEL); |
| 1352 | if (!blport) { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1353 | BNX2FC_HBA_DBG(interface->ctlr.lp, "Unable to alloc blport\n"); |
Bhanu Prakash Gollapudi | d36b327 | 2011-05-27 11:47:27 -0700 | [diff] [blame] | 1354 | return NULL; |
| 1355 | } |
| 1356 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1357 | /* Allocate Scsi_Host structure */ |
Vasu Dev | 134a4e2 | 2011-04-28 15:55:44 -0700 | [diff] [blame] | 1358 | if (!npiv) |
| 1359 | lport = libfc_host_alloc(&bnx2fc_shost_template, sizeof(*port)); |
| 1360 | else |
| 1361 | lport = libfc_vport_create(vport, sizeof(*port)); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1362 | |
| 1363 | if (!lport) { |
| 1364 | printk(KERN_ERR PFX "could not allocate scsi host structure\n"); |
Bhanu Prakash Gollapudi | d36b327 | 2011-05-27 11:47:27 -0700 | [diff] [blame] | 1365 | goto free_blport; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1366 | } |
| 1367 | shost = lport->host; |
| 1368 | port = lport_priv(lport); |
| 1369 | port->lport = lport; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1370 | port->priv = interface; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1371 | INIT_WORK(&port->destroy_work, bnx2fc_destroy_work); |
| 1372 | |
| 1373 | /* Configure fcoe_port */ |
| 1374 | rc = bnx2fc_lport_config(lport); |
| 1375 | if (rc) |
| 1376 | goto lp_config_err; |
| 1377 | |
| 1378 | if (npiv) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1379 | printk(KERN_ERR PFX "Setting vport names, 0x%llX 0x%llX\n", |
| 1380 | vport->node_name, vport->port_name); |
| 1381 | fc_set_wwnn(lport, vport->node_name); |
| 1382 | fc_set_wwpn(lport, vport->port_name); |
| 1383 | } |
| 1384 | /* Configure netdev and networking properties of the lport */ |
Bhanu Prakash Gollapudi | 5243960 | 2011-08-04 17:38:50 -0700 | [diff] [blame] | 1385 | rc = bnx2fc_net_config(lport, interface->netdev); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1386 | if (rc) { |
| 1387 | printk(KERN_ERR PFX "Error on bnx2fc_net_config\n"); |
| 1388 | goto lp_config_err; |
| 1389 | } |
| 1390 | |
| 1391 | rc = bnx2fc_shost_config(lport, parent); |
| 1392 | if (rc) { |
| 1393 | printk(KERN_ERR PFX "Couldnt configure shost for %s\n", |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1394 | interface->netdev->name); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1395 | goto lp_config_err; |
| 1396 | } |
| 1397 | |
| 1398 | /* Initialize the libfc library */ |
| 1399 | rc = bnx2fc_libfc_config(lport); |
| 1400 | if (rc) { |
| 1401 | printk(KERN_ERR PFX "Couldnt configure libfc\n"); |
| 1402 | goto shost_err; |
| 1403 | } |
| 1404 | fc_host_port_type(lport->host) = FC_PORTTYPE_UNKNOWN; |
| 1405 | |
| 1406 | /* Allocate exchange manager */ |
Vasu Dev | 134a4e2 | 2011-04-28 15:55:44 -0700 | [diff] [blame] | 1407 | if (!npiv) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1408 | rc = bnx2fc_em_config(lport); |
Vasu Dev | 134a4e2 | 2011-04-28 15:55:44 -0700 | [diff] [blame] | 1409 | else { |
| 1410 | shost = vport_to_shost(vport); |
| 1411 | n_port = shost_priv(shost); |
| 1412 | rc = fc_exch_mgr_list_clone(n_port, lport); |
| 1413 | } |
| 1414 | |
| 1415 | if (rc) { |
| 1416 | printk(KERN_ERR PFX "Error on bnx2fc_em_config\n"); |
| 1417 | goto shost_err; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1418 | } |
| 1419 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1420 | bnx2fc_interface_get(interface); |
Bhanu Prakash Gollapudi | d36b327 | 2011-05-27 11:47:27 -0700 | [diff] [blame] | 1421 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1422 | hba = interface->hba; |
Bhanu Prakash Gollapudi | d36b327 | 2011-05-27 11:47:27 -0700 | [diff] [blame] | 1423 | spin_lock_bh(&hba->hba_lock); |
| 1424 | blport->lport = lport; |
| 1425 | list_add_tail(&blport->list, &hba->vports); |
| 1426 | spin_unlock_bh(&hba->hba_lock); |
| 1427 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1428 | return lport; |
| 1429 | |
| 1430 | shost_err: |
| 1431 | scsi_remove_host(shost); |
| 1432 | lp_config_err: |
| 1433 | scsi_host_put(lport->host); |
Bhanu Prakash Gollapudi | d36b327 | 2011-05-27 11:47:27 -0700 | [diff] [blame] | 1434 | free_blport: |
| 1435 | kfree(blport); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1436 | return NULL; |
| 1437 | } |
| 1438 | |
Bhanu Prakash Gollapudi | 776cebc | 2011-08-04 17:38:40 -0700 | [diff] [blame] | 1439 | static void bnx2fc_interface_cleanup(struct bnx2fc_interface *interface) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1440 | { |
Bhanu Prakash Gollapudi | 9be17fc | 2011-08-04 17:38:41 -0700 | [diff] [blame] | 1441 | struct fc_lport *lport = interface->ctlr.lp; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1442 | struct fcoe_port *port = lport_priv(lport); |
Bhanu Prakash Gollapudi | 9be17fc | 2011-08-04 17:38:41 -0700 | [diff] [blame] | 1443 | struct bnx2fc_hba *hba = interface->hba; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1444 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1445 | /* Stop the transmit retry timer */ |
| 1446 | del_timer_sync(&port->timer); |
| 1447 | |
| 1448 | /* Free existing transmit skbs */ |
| 1449 | fcoe_clean_pending_queue(lport); |
| 1450 | |
Bhanu Prakash Gollapudi | 9be17fc | 2011-08-04 17:38:41 -0700 | [diff] [blame] | 1451 | /* Dont listen for Ethernet packets anymore */ |
| 1452 | __dev_remove_pack(&interface->fcoe_packet_type); |
| 1453 | __dev_remove_pack(&interface->fip_packet_type); |
| 1454 | synchronize_net(); |
| 1455 | |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 1456 | bnx2fc_free_vport(hba, lport); |
Bhanu Prakash Gollapudi | 9be17fc | 2011-08-04 17:38:41 -0700 | [diff] [blame] | 1457 | } |
| 1458 | |
| 1459 | static void bnx2fc_if_destroy(struct fc_lport *lport) |
| 1460 | { |
| 1461 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1462 | /* Free queued packets for the receive thread */ |
| 1463 | bnx2fc_clean_rx_queue(lport); |
| 1464 | |
| 1465 | /* Detach from scsi-ml */ |
| 1466 | fc_remove_host(lport->host); |
| 1467 | scsi_remove_host(lport->host); |
| 1468 | |
| 1469 | /* |
| 1470 | * Note that only the physical lport will have the exchange manager. |
| 1471 | * for vports, this function is NOP |
| 1472 | */ |
| 1473 | fc_exch_mgr_free(lport); |
| 1474 | |
| 1475 | /* Free memory used by statistical counters */ |
| 1476 | fc_lport_free_stats(lport); |
| 1477 | |
| 1478 | /* Release Scsi_Host */ |
| 1479 | scsi_host_put(lport->host); |
| 1480 | } |
| 1481 | |
Bhanu Prakash Gollapudi | eccdcd0 | 2011-08-24 18:56:42 -0700 | [diff] [blame^] | 1482 | static void __bnx2fc_destroy(struct bnx2fc_interface *interface) |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 1483 | { |
| 1484 | struct fc_lport *lport = interface->ctlr.lp; |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 1485 | |
| 1486 | bnx2fc_interface_cleanup(interface); |
| 1487 | bnx2fc_stop(interface); |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 1488 | list_del(&interface->list); |
| 1489 | lport = interface->ctlr.lp; |
| 1490 | bnx2fc_interface_put(interface); |
Bhanu Prakash Gollapudi | eccdcd0 | 2011-08-24 18:56:42 -0700 | [diff] [blame^] | 1491 | bnx2fc_if_destroy(lport); |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 1492 | } |
| 1493 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1494 | /** |
| 1495 | * bnx2fc_destroy - Destroy a bnx2fc FCoE interface |
| 1496 | * |
| 1497 | * @buffer: The name of the Ethernet interface to be destroyed |
| 1498 | * @kp: The associated kernel parameter |
| 1499 | * |
| 1500 | * Called from sysfs. |
| 1501 | * |
| 1502 | * Returns: 0 for success |
| 1503 | */ |
| 1504 | static int bnx2fc_destroy(struct net_device *netdev) |
| 1505 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1506 | struct bnx2fc_interface *interface = NULL; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1507 | int rc = 0; |
| 1508 | |
Nithin Sujir | 6702ca1 | 2011-03-17 17:13:27 -0700 | [diff] [blame] | 1509 | rtnl_lock(); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1510 | mutex_lock(&bnx2fc_dev_lock); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1511 | |
| 1512 | interface = bnx2fc_interface_lookup(netdev); |
| 1513 | if (!interface || !interface->ctlr.lp) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1514 | rc = -ENODEV; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1515 | printk(KERN_ERR PFX "bnx2fc_destroy: interface or lport not found\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1516 | goto netdev_err; |
| 1517 | } |
| 1518 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1519 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1520 | destroy_workqueue(interface->timer_work_queue); |
Bhanu Prakash Gollapudi | eccdcd0 | 2011-08-24 18:56:42 -0700 | [diff] [blame^] | 1521 | __bnx2fc_destroy(interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1522 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1523 | netdev_err: |
| 1524 | mutex_unlock(&bnx2fc_dev_lock); |
| 1525 | rtnl_unlock(); |
| 1526 | return rc; |
| 1527 | } |
| 1528 | |
| 1529 | static void bnx2fc_destroy_work(struct work_struct *work) |
| 1530 | { |
| 1531 | struct fcoe_port *port; |
| 1532 | struct fc_lport *lport; |
| 1533 | |
| 1534 | port = container_of(work, struct fcoe_port, destroy_work); |
| 1535 | lport = port->lport; |
| 1536 | |
| 1537 | BNX2FC_HBA_DBG(lport, "Entered bnx2fc_destroy_work\n"); |
| 1538 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1539 | rtnl_lock(); |
| 1540 | mutex_lock(&bnx2fc_dev_lock); |
Bhanu Prakash Gollapudi | 9be17fc | 2011-08-04 17:38:41 -0700 | [diff] [blame] | 1541 | bnx2fc_if_destroy(lport); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1542 | mutex_unlock(&bnx2fc_dev_lock); |
| 1543 | rtnl_unlock(); |
| 1544 | } |
| 1545 | |
| 1546 | static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba) |
| 1547 | { |
| 1548 | bnx2fc_free_fw_resc(hba); |
| 1549 | bnx2fc_free_task_ctx(hba); |
| 1550 | } |
| 1551 | |
| 1552 | /** |
| 1553 | * bnx2fc_bind_adapter_devices - binds bnx2fc adapter with the associated |
| 1554 | * pci structure |
| 1555 | * |
| 1556 | * @hba: Adapter instance |
| 1557 | */ |
| 1558 | static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba) |
| 1559 | { |
| 1560 | if (bnx2fc_setup_task_ctx(hba)) |
| 1561 | goto mem_err; |
| 1562 | |
| 1563 | if (bnx2fc_setup_fw_resc(hba)) |
| 1564 | goto mem_err; |
| 1565 | |
| 1566 | return 0; |
| 1567 | mem_err: |
| 1568 | bnx2fc_unbind_adapter_devices(hba); |
| 1569 | return -ENOMEM; |
| 1570 | } |
| 1571 | |
| 1572 | static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba) |
| 1573 | { |
| 1574 | struct cnic_dev *cnic; |
| 1575 | |
| 1576 | if (!hba->cnic) { |
| 1577 | printk(KERN_ERR PFX "cnic is NULL\n"); |
| 1578 | return -ENODEV; |
| 1579 | } |
| 1580 | cnic = hba->cnic; |
| 1581 | hba->pcidev = cnic->pcidev; |
| 1582 | if (hba->pcidev) |
| 1583 | pci_dev_get(hba->pcidev); |
| 1584 | |
| 1585 | return 0; |
| 1586 | } |
| 1587 | |
| 1588 | static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba) |
| 1589 | { |
| 1590 | if (hba->pcidev) |
| 1591 | pci_dev_put(hba->pcidev); |
| 1592 | hba->pcidev = NULL; |
| 1593 | } |
| 1594 | |
| 1595 | |
| 1596 | |
| 1597 | /** |
| 1598 | * bnx2fc_ulp_start - cnic callback to initialize & start adapter instance |
| 1599 | * |
| 1600 | * @handle: transport handle pointing to adapter struture |
| 1601 | * |
| 1602 | * This function maps adapter structure to pcidev structure and initiates |
| 1603 | * firmware handshake to enable/initialize on-chip FCoE components. |
| 1604 | * This bnx2fc - cnic interface api callback is used after following |
| 1605 | * conditions are met - |
| 1606 | * a) underlying network interface is up (marked by event NETDEV_UP |
| 1607 | * from netdev |
| 1608 | * b) bnx2fc adatper structure is registered. |
| 1609 | */ |
| 1610 | static void bnx2fc_ulp_start(void *handle) |
| 1611 | { |
| 1612 | struct bnx2fc_hba *hba = handle; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1613 | struct bnx2fc_interface *interface; |
| 1614 | struct fc_lport *lport; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1615 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1616 | mutex_lock(&bnx2fc_dev_lock); |
| 1617 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1618 | if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1619 | bnx2fc_fw_init(hba); |
| 1620 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1621 | BNX2FC_MISC_DBG("bnx2fc started.\n"); |
| 1622 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1623 | list_for_each_entry(interface, &if_list, list) { |
| 1624 | if (interface->hba == hba) { |
| 1625 | lport = interface->ctlr.lp; |
| 1626 | /* Kick off Fabric discovery*/ |
| 1627 | printk(KERN_ERR PFX "ulp_init: start discovery\n"); |
| 1628 | lport->tt.frame_send = bnx2fc_xmit; |
| 1629 | bnx2fc_start_disc(interface); |
| 1630 | } |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1631 | } |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1632 | |
| 1633 | mutex_unlock(&bnx2fc_dev_lock); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1634 | } |
| 1635 | |
| 1636 | static void bnx2fc_port_shutdown(struct fc_lport *lport) |
| 1637 | { |
| 1638 | BNX2FC_MISC_DBG("Entered %s\n", __func__); |
| 1639 | fc_fabric_logoff(lport); |
| 1640 | fc_lport_destroy(lport); |
| 1641 | } |
| 1642 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1643 | static void bnx2fc_stop(struct bnx2fc_interface *interface) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1644 | { |
| 1645 | struct fc_lport *lport; |
| 1646 | struct fc_lport *vport; |
| 1647 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1648 | if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) |
| 1649 | return; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1650 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1651 | lport = interface->ctlr.lp; |
| 1652 | bnx2fc_port_shutdown(lport); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1653 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1654 | mutex_lock(&lport->lp_mutex); |
| 1655 | list_for_each_entry(vport, &lport->vports, list) |
| 1656 | fc_host_port_type(vport->host) = |
| 1657 | FC_PORTTYPE_UNKNOWN; |
| 1658 | mutex_unlock(&lport->lp_mutex); |
| 1659 | fc_host_port_type(lport->host) = FC_PORTTYPE_UNKNOWN; |
| 1660 | fcoe_ctlr_link_down(&interface->ctlr); |
| 1661 | fcoe_clean_pending_queue(lport); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1662 | } |
| 1663 | |
| 1664 | static int bnx2fc_fw_init(struct bnx2fc_hba *hba) |
| 1665 | { |
| 1666 | #define BNX2FC_INIT_POLL_TIME (1000 / HZ) |
| 1667 | int rc = -1; |
| 1668 | int i = HZ; |
| 1669 | |
| 1670 | rc = bnx2fc_bind_adapter_devices(hba); |
| 1671 | if (rc) { |
| 1672 | printk(KERN_ALERT PFX |
| 1673 | "bnx2fc_bind_adapter_devices failed - rc = %d\n", rc); |
| 1674 | goto err_out; |
| 1675 | } |
| 1676 | |
| 1677 | rc = bnx2fc_send_fw_fcoe_init_msg(hba); |
| 1678 | if (rc) { |
| 1679 | printk(KERN_ALERT PFX |
| 1680 | "bnx2fc_send_fw_fcoe_init_msg failed - rc = %d\n", rc); |
| 1681 | goto err_unbind; |
| 1682 | } |
| 1683 | |
| 1684 | /* |
| 1685 | * Wait until the adapter init message is complete, and adapter |
| 1686 | * state is UP. |
| 1687 | */ |
| 1688 | while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--) |
| 1689 | msleep(BNX2FC_INIT_POLL_TIME); |
| 1690 | |
| 1691 | if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) { |
| 1692 | printk(KERN_ERR PFX "bnx2fc_start: %s failed to initialize. " |
| 1693 | "Ignoring...\n", |
| 1694 | hba->cnic->netdev->name); |
| 1695 | rc = -1; |
| 1696 | goto err_unbind; |
| 1697 | } |
| 1698 | |
| 1699 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1700 | set_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1701 | return 0; |
| 1702 | |
| 1703 | err_unbind: |
| 1704 | bnx2fc_unbind_adapter_devices(hba); |
| 1705 | err_out: |
| 1706 | return rc; |
| 1707 | } |
| 1708 | |
| 1709 | static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba) |
| 1710 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1711 | if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1712 | if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) { |
| 1713 | init_timer(&hba->destroy_timer); |
| 1714 | hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT + |
| 1715 | jiffies; |
| 1716 | hba->destroy_timer.function = bnx2fc_destroy_timer; |
| 1717 | hba->destroy_timer.data = (unsigned long)hba; |
| 1718 | add_timer(&hba->destroy_timer); |
| 1719 | wait_event_interruptible(hba->destroy_wait, |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1720 | test_bit(BNX2FC_FLAG_DESTROY_CMPL, |
| 1721 | &hba->flags)); |
Bhanu Prakash Gollapudi | cd703ae | 2011-08-04 17:38:43 -0700 | [diff] [blame] | 1722 | clear_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1723 | /* This should never happen */ |
| 1724 | if (signal_pending(current)) |
| 1725 | flush_signals(current); |
| 1726 | |
| 1727 | del_timer_sync(&hba->destroy_timer); |
| 1728 | } |
| 1729 | bnx2fc_unbind_adapter_devices(hba); |
| 1730 | } |
| 1731 | } |
| 1732 | |
| 1733 | /** |
| 1734 | * bnx2fc_ulp_stop - cnic callback to shutdown adapter instance |
| 1735 | * |
| 1736 | * @handle: transport handle pointing to adapter structure |
| 1737 | * |
| 1738 | * Driver checks if adapter is already in shutdown mode, if not start |
| 1739 | * the shutdown process. |
| 1740 | */ |
| 1741 | static void bnx2fc_ulp_stop(void *handle) |
| 1742 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1743 | struct bnx2fc_hba *hba = handle; |
| 1744 | struct bnx2fc_interface *interface; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1745 | |
| 1746 | printk(KERN_ERR "ULP_STOP\n"); |
| 1747 | |
| 1748 | mutex_lock(&bnx2fc_dev_lock); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1749 | if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) |
| 1750 | goto exit; |
| 1751 | list_for_each_entry(interface, &if_list, list) { |
| 1752 | if (interface->hba == hba) |
| 1753 | bnx2fc_stop(interface); |
| 1754 | } |
| 1755 | BUG_ON(hba->num_ofld_sess != 0); |
| 1756 | |
| 1757 | mutex_lock(&hba->hba_mutex); |
| 1758 | clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); |
| 1759 | clear_bit(ADAPTER_STATE_GOING_DOWN, |
| 1760 | &hba->adapter_state); |
| 1761 | |
| 1762 | clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); |
| 1763 | mutex_unlock(&hba->hba_mutex); |
| 1764 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1765 | bnx2fc_fw_destroy(hba); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1766 | exit: |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1767 | mutex_unlock(&bnx2fc_dev_lock); |
| 1768 | } |
| 1769 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1770 | static void bnx2fc_start_disc(struct bnx2fc_interface *interface) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1771 | { |
| 1772 | struct fc_lport *lport; |
| 1773 | int wait_cnt = 0; |
| 1774 | |
| 1775 | BNX2FC_MISC_DBG("Entered %s\n", __func__); |
| 1776 | /* Kick off FIP/FLOGI */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1777 | if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1778 | printk(KERN_ERR PFX "Init not done yet\n"); |
| 1779 | return; |
| 1780 | } |
| 1781 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1782 | lport = interface->ctlr.lp; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1783 | BNX2FC_HBA_DBG(lport, "calling fc_fabric_login\n"); |
| 1784 | |
| 1785 | if (!bnx2fc_link_ok(lport)) { |
| 1786 | BNX2FC_HBA_DBG(lport, "ctlr_link_up\n"); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1787 | fcoe_ctlr_link_up(&interface->ctlr); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1788 | fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1789 | set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1790 | } |
| 1791 | |
| 1792 | /* wait for the FCF to be selected before issuing FLOGI */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1793 | while (!interface->ctlr.sel_fcf) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1794 | msleep(250); |
| 1795 | /* give up after 3 secs */ |
| 1796 | if (++wait_cnt > 12) |
| 1797 | break; |
| 1798 | } |
Bhanu Prakash Gollapudi | 627e628 | 2011-08-04 17:38:35 -0700 | [diff] [blame] | 1799 | |
| 1800 | /* Reset max receive frame size to default */ |
| 1801 | if (fc_set_mfs(lport, BNX2FC_MFS)) |
| 1802 | return; |
| 1803 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1804 | fc_lport_init(lport); |
| 1805 | fc_fabric_login(lport); |
| 1806 | } |
| 1807 | |
| 1808 | |
| 1809 | /** |
| 1810 | * bnx2fc_ulp_init - Initialize an adapter instance |
| 1811 | * |
| 1812 | * @dev : cnic device handle |
| 1813 | * Called from cnic_register_driver() context to initialize all |
| 1814 | * enumerated cnic devices. This routine allocates adapter structure |
| 1815 | * and other device specific resources. |
| 1816 | */ |
| 1817 | static void bnx2fc_ulp_init(struct cnic_dev *dev) |
| 1818 | { |
| 1819 | struct bnx2fc_hba *hba; |
| 1820 | int rc = 0; |
| 1821 | |
| 1822 | BNX2FC_MISC_DBG("Entered %s\n", __func__); |
| 1823 | /* bnx2fc works only when bnx2x is loaded */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1824 | if (!test_bit(CNIC_F_BNX2X_CLASS, &dev->flags) || |
| 1825 | (dev->max_fcoe_conn == 0)) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1826 | printk(KERN_ERR PFX "bnx2fc FCoE not supported on %s," |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1827 | " flags: %lx fcoe_conn: %d\n", |
| 1828 | dev->netdev->name, dev->flags, dev->max_fcoe_conn); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1829 | return; |
| 1830 | } |
| 1831 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1832 | hba = bnx2fc_hba_create(dev); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1833 | if (!hba) { |
| 1834 | printk(KERN_ERR PFX "hba initialization failed\n"); |
| 1835 | return; |
| 1836 | } |
| 1837 | |
| 1838 | /* Add HBA to the adapter list */ |
| 1839 | mutex_lock(&bnx2fc_dev_lock); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1840 | list_add_tail(&hba->list, &adapter_list); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1841 | adapter_count++; |
| 1842 | mutex_unlock(&bnx2fc_dev_lock); |
| 1843 | |
| 1844 | clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); |
| 1845 | rc = dev->register_device(dev, CNIC_ULP_FCOE, |
| 1846 | (void *) hba); |
| 1847 | if (rc) |
Bhanu Prakash Gollapudi | b2a554f | 2011-06-27 23:30:53 -0700 | [diff] [blame] | 1848 | printk(KERN_ERR PFX "register_device failed, rc = %d\n", rc); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1849 | else |
| 1850 | set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); |
| 1851 | } |
| 1852 | |
| 1853 | |
| 1854 | static int bnx2fc_disable(struct net_device *netdev) |
| 1855 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1856 | struct bnx2fc_interface *interface; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1857 | int rc = 0; |
| 1858 | |
Nithin Sujir | 6702ca1 | 2011-03-17 17:13:27 -0700 | [diff] [blame] | 1859 | rtnl_lock(); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1860 | mutex_lock(&bnx2fc_dev_lock); |
| 1861 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1862 | interface = bnx2fc_interface_lookup(netdev); |
| 1863 | if (!interface || !interface->ctlr.lp) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1864 | rc = -ENODEV; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1865 | printk(KERN_ERR PFX "bnx2fc_disable: interface or lport not found\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1866 | } else { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1867 | fcoe_ctlr_link_down(&interface->ctlr); |
| 1868 | fcoe_clean_pending_queue(interface->ctlr.lp); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1869 | } |
| 1870 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1871 | mutex_unlock(&bnx2fc_dev_lock); |
| 1872 | rtnl_unlock(); |
| 1873 | return rc; |
| 1874 | } |
| 1875 | |
| 1876 | |
| 1877 | static int bnx2fc_enable(struct net_device *netdev) |
| 1878 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1879 | struct bnx2fc_interface *interface; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1880 | int rc = 0; |
| 1881 | |
Nithin Sujir | 6702ca1 | 2011-03-17 17:13:27 -0700 | [diff] [blame] | 1882 | rtnl_lock(); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1883 | mutex_lock(&bnx2fc_dev_lock); |
| 1884 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1885 | interface = bnx2fc_interface_lookup(netdev); |
| 1886 | if (!interface || !interface->ctlr.lp) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1887 | rc = -ENODEV; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1888 | printk(KERN_ERR PFX "bnx2fc_enable: interface or lport not found\n"); |
| 1889 | } else if (!bnx2fc_link_ok(interface->ctlr.lp)) |
| 1890 | fcoe_ctlr_link_up(&interface->ctlr); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1891 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1892 | mutex_unlock(&bnx2fc_dev_lock); |
| 1893 | rtnl_unlock(); |
| 1894 | return rc; |
| 1895 | } |
| 1896 | |
| 1897 | /** |
| 1898 | * bnx2fc_create - Create bnx2fc FCoE interface |
| 1899 | * |
| 1900 | * @buffer: The name of Ethernet interface to create on |
| 1901 | * @kp: The associated kernel param |
| 1902 | * |
| 1903 | * Called from sysfs. |
| 1904 | * |
| 1905 | * Returns: 0 for success |
| 1906 | */ |
| 1907 | static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode) |
| 1908 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1909 | struct bnx2fc_interface *interface; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1910 | struct bnx2fc_hba *hba; |
| 1911 | struct net_device *phys_dev; |
| 1912 | struct fc_lport *lport; |
| 1913 | struct ethtool_drvinfo drvinfo; |
| 1914 | int rc = 0; |
| 1915 | int vlan_id; |
| 1916 | |
| 1917 | BNX2FC_MISC_DBG("Entered bnx2fc_create\n"); |
| 1918 | if (fip_mode != FIP_MODE_FABRIC) { |
| 1919 | printk(KERN_ERR "fip mode not FABRIC\n"); |
| 1920 | return -EIO; |
| 1921 | } |
| 1922 | |
Nithin Sujir | 6702ca1 | 2011-03-17 17:13:27 -0700 | [diff] [blame] | 1923 | rtnl_lock(); |
| 1924 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1925 | mutex_lock(&bnx2fc_dev_lock); |
| 1926 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1927 | if (!try_module_get(THIS_MODULE)) { |
| 1928 | rc = -EINVAL; |
| 1929 | goto mod_err; |
| 1930 | } |
| 1931 | |
| 1932 | /* obtain physical netdev */ |
| 1933 | if (netdev->priv_flags & IFF_802_1Q_VLAN) { |
| 1934 | phys_dev = vlan_dev_real_dev(netdev); |
| 1935 | vlan_id = vlan_dev_vlan_id(netdev); |
| 1936 | } else { |
| 1937 | printk(KERN_ERR PFX "Not a vlan device\n"); |
| 1938 | rc = -EINVAL; |
| 1939 | goto netdev_err; |
| 1940 | } |
| 1941 | /* verify if the physical device is a netxtreme2 device */ |
| 1942 | if (phys_dev->ethtool_ops && phys_dev->ethtool_ops->get_drvinfo) { |
| 1943 | memset(&drvinfo, 0, sizeof(drvinfo)); |
| 1944 | phys_dev->ethtool_ops->get_drvinfo(phys_dev, &drvinfo); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1945 | if (strncmp(drvinfo.driver, "bnx2x", strlen("bnx2x"))) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1946 | printk(KERN_ERR PFX "Not a netxtreme2 device\n"); |
| 1947 | rc = -EINVAL; |
| 1948 | goto netdev_err; |
| 1949 | } |
| 1950 | } else { |
| 1951 | printk(KERN_ERR PFX "unable to obtain drv_info\n"); |
| 1952 | rc = -EINVAL; |
| 1953 | goto netdev_err; |
| 1954 | } |
| 1955 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1956 | /* obtain interface and initialize rest of the structure */ |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1957 | hba = bnx2fc_hba_lookup(phys_dev); |
| 1958 | if (!hba) { |
| 1959 | rc = -ENODEV; |
| 1960 | printk(KERN_ERR PFX "bnx2fc_create: hba not found\n"); |
| 1961 | goto netdev_err; |
| 1962 | } |
| 1963 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1964 | if (bnx2fc_interface_lookup(netdev)) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1965 | rc = -EEXIST; |
| 1966 | goto netdev_err; |
| 1967 | } |
| 1968 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1969 | interface = bnx2fc_interface_create(hba, netdev, fip_mode); |
| 1970 | if (!interface) { |
| 1971 | printk(KERN_ERR PFX "bnx2fc_interface_create failed\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1972 | goto ifput_err; |
| 1973 | } |
| 1974 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1975 | interface->vlan_id = vlan_id; |
| 1976 | interface->vlan_enabled = 1; |
| 1977 | |
| 1978 | interface->timer_work_queue = |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1979 | create_singlethread_workqueue("bnx2fc_timer_wq"); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1980 | if (!interface->timer_work_queue) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1981 | printk(KERN_ERR PFX "ulp_init could not create timer_wq\n"); |
| 1982 | rc = -EINVAL; |
| 1983 | goto ifput_err; |
| 1984 | } |
| 1985 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1986 | lport = bnx2fc_if_create(interface, &interface->hba->pcidev->dev, 0); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1987 | if (!lport) { |
| 1988 | printk(KERN_ERR PFX "Failed to create interface (%s)\n", |
| 1989 | netdev->name); |
Bhanu Prakash Gollapudi | 776cebc | 2011-08-04 17:38:40 -0700 | [diff] [blame] | 1990 | bnx2fc_interface_cleanup(interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1991 | rc = -EINVAL; |
| 1992 | goto if_create_err; |
| 1993 | } |
| 1994 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 1995 | /* Add interface to if_list */ |
| 1996 | list_add_tail(&interface->list, &if_list); |
| 1997 | |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 1998 | lport->boot_time = jiffies; |
| 1999 | |
| 2000 | /* Make this master N_port */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2001 | interface->ctlr.lp = lport; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2002 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2003 | BNX2FC_HBA_DBG(lport, "create: START DISC\n"); |
| 2004 | bnx2fc_start_disc(interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2005 | /* |
| 2006 | * Release from kref_init in bnx2fc_interface_setup, on success |
| 2007 | * lport should be holding a reference taken in bnx2fc_if_create |
| 2008 | */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2009 | bnx2fc_interface_put(interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2010 | /* put netdev that was held while calling dev_get_by_name */ |
| 2011 | mutex_unlock(&bnx2fc_dev_lock); |
| 2012 | rtnl_unlock(); |
| 2013 | return 0; |
| 2014 | |
| 2015 | if_create_err: |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2016 | destroy_workqueue(interface->timer_work_queue); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2017 | ifput_err: |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2018 | bnx2fc_interface_put(interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2019 | netdev_err: |
| 2020 | module_put(THIS_MODULE); |
| 2021 | mod_err: |
| 2022 | mutex_unlock(&bnx2fc_dev_lock); |
| 2023 | rtnl_unlock(); |
| 2024 | return rc; |
| 2025 | } |
| 2026 | |
| 2027 | /** |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2028 | * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2029 | * |
| 2030 | * @cnic: Pointer to cnic device instance |
| 2031 | * |
| 2032 | **/ |
| 2033 | static struct bnx2fc_hba *bnx2fc_find_hba_for_cnic(struct cnic_dev *cnic) |
| 2034 | { |
| 2035 | struct list_head *list; |
| 2036 | struct list_head *temp; |
| 2037 | struct bnx2fc_hba *hba; |
| 2038 | |
| 2039 | /* Called with bnx2fc_dev_lock held */ |
| 2040 | list_for_each_safe(list, temp, &adapter_list) { |
| 2041 | hba = (struct bnx2fc_hba *)list; |
| 2042 | if (hba->cnic == cnic) |
| 2043 | return hba; |
| 2044 | } |
| 2045 | return NULL; |
| 2046 | } |
| 2047 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2048 | static struct bnx2fc_interface *bnx2fc_interface_lookup(struct net_device |
| 2049 | *netdev) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2050 | { |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2051 | struct bnx2fc_interface *interface; |
| 2052 | |
| 2053 | /* Called with bnx2fc_dev_lock held */ |
| 2054 | list_for_each_entry(interface, &if_list, list) { |
| 2055 | if (interface->netdev == netdev) |
| 2056 | return interface; |
| 2057 | } |
| 2058 | return NULL; |
| 2059 | } |
| 2060 | |
| 2061 | static struct bnx2fc_hba *bnx2fc_hba_lookup(struct net_device |
| 2062 | *phys_dev) |
| 2063 | { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2064 | struct bnx2fc_hba *hba; |
| 2065 | |
| 2066 | /* Called with bnx2fc_dev_lock held */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2067 | list_for_each_entry(hba, &adapter_list, list) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2068 | if (hba->phys_dev == phys_dev) |
| 2069 | return hba; |
| 2070 | } |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2071 | printk(KERN_ERR PFX "adapter_lookup: hba NULL\n"); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2072 | return NULL; |
| 2073 | } |
| 2074 | |
| 2075 | /** |
| 2076 | * bnx2fc_ulp_exit - shuts down adapter instance and frees all resources |
| 2077 | * |
| 2078 | * @dev cnic device handle |
| 2079 | */ |
| 2080 | static void bnx2fc_ulp_exit(struct cnic_dev *dev) |
| 2081 | { |
| 2082 | struct bnx2fc_hba *hba; |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2083 | struct bnx2fc_interface *interface, *tmp; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2084 | |
| 2085 | BNX2FC_MISC_DBG("Entered bnx2fc_ulp_exit\n"); |
| 2086 | |
| 2087 | if (!test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { |
| 2088 | printk(KERN_ERR PFX "bnx2fc port check: %s, flags: %lx\n", |
| 2089 | dev->netdev->name, dev->flags); |
| 2090 | return; |
| 2091 | } |
| 2092 | |
| 2093 | mutex_lock(&bnx2fc_dev_lock); |
| 2094 | hba = bnx2fc_find_hba_for_cnic(dev); |
| 2095 | if (!hba) { |
| 2096 | printk(KERN_ERR PFX "bnx2fc_ulp_exit: hba not found, dev 0%p\n", |
| 2097 | dev); |
| 2098 | mutex_unlock(&bnx2fc_dev_lock); |
| 2099 | return; |
| 2100 | } |
| 2101 | |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2102 | list_del_init(&hba->list); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2103 | adapter_count--; |
| 2104 | |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 2105 | list_for_each_entry_safe(interface, tmp, &if_list, list) |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2106 | /* destroy not called yet, move to quiesced list */ |
Bhanu Prakash Gollapudi | abc49a9 | 2011-08-04 17:38:42 -0700 | [diff] [blame] | 2107 | if (interface->hba == hba) |
Bhanu Prakash Gollapudi | eccdcd0 | 2011-08-24 18:56:42 -0700 | [diff] [blame^] | 2108 | __bnx2fc_destroy(interface); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2109 | mutex_unlock(&bnx2fc_dev_lock); |
| 2110 | |
| 2111 | bnx2fc_ulp_stop(hba); |
| 2112 | /* unregister cnic device */ |
| 2113 | if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic)) |
| 2114 | hba->cnic->unregister_device(hba->cnic, CNIC_ULP_FCOE); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2115 | bnx2fc_hba_destroy(hba); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2116 | } |
| 2117 | |
| 2118 | /** |
| 2119 | * bnx2fc_fcoe_reset - Resets the fcoe |
| 2120 | * |
| 2121 | * @shost: shost the reset is from |
| 2122 | * |
| 2123 | * Returns: always 0 |
| 2124 | */ |
| 2125 | static int bnx2fc_fcoe_reset(struct Scsi_Host *shost) |
| 2126 | { |
| 2127 | struct fc_lport *lport = shost_priv(shost); |
| 2128 | fc_lport_reset(lport); |
| 2129 | return 0; |
| 2130 | } |
| 2131 | |
| 2132 | |
| 2133 | static bool bnx2fc_match(struct net_device *netdev) |
| 2134 | { |
| 2135 | mutex_lock(&bnx2fc_dev_lock); |
| 2136 | if (netdev->priv_flags & IFF_802_1Q_VLAN) { |
| 2137 | struct net_device *phys_dev = vlan_dev_real_dev(netdev); |
| 2138 | |
| 2139 | if (bnx2fc_hba_lookup(phys_dev)) { |
| 2140 | mutex_unlock(&bnx2fc_dev_lock); |
| 2141 | return true; |
| 2142 | } |
| 2143 | } |
| 2144 | mutex_unlock(&bnx2fc_dev_lock); |
| 2145 | return false; |
| 2146 | } |
| 2147 | |
| 2148 | |
| 2149 | static struct fcoe_transport bnx2fc_transport = { |
| 2150 | .name = {"bnx2fc"}, |
| 2151 | .attached = false, |
| 2152 | .list = LIST_HEAD_INIT(bnx2fc_transport.list), |
| 2153 | .match = bnx2fc_match, |
| 2154 | .create = bnx2fc_create, |
| 2155 | .destroy = bnx2fc_destroy, |
| 2156 | .enable = bnx2fc_enable, |
| 2157 | .disable = bnx2fc_disable, |
| 2158 | }; |
| 2159 | |
| 2160 | /** |
| 2161 | * bnx2fc_percpu_thread_create - Create a receive thread for an |
| 2162 | * online CPU |
| 2163 | * |
| 2164 | * @cpu: cpu index for the online cpu |
| 2165 | */ |
| 2166 | static void bnx2fc_percpu_thread_create(unsigned int cpu) |
| 2167 | { |
| 2168 | struct bnx2fc_percpu_s *p; |
| 2169 | struct task_struct *thread; |
| 2170 | |
| 2171 | p = &per_cpu(bnx2fc_percpu, cpu); |
| 2172 | |
| 2173 | thread = kthread_create(bnx2fc_percpu_io_thread, |
| 2174 | (void *)p, |
| 2175 | "bnx2fc_thread/%d", cpu); |
| 2176 | /* bind thread to the cpu */ |
Bhanu Prakash Gollapudi | 3224876 | 2011-08-04 17:38:36 -0700 | [diff] [blame] | 2177 | if (likely(!IS_ERR(thread))) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2178 | kthread_bind(thread, cpu); |
| 2179 | p->iothread = thread; |
| 2180 | wake_up_process(thread); |
| 2181 | } |
| 2182 | } |
| 2183 | |
| 2184 | static void bnx2fc_percpu_thread_destroy(unsigned int cpu) |
| 2185 | { |
| 2186 | struct bnx2fc_percpu_s *p; |
| 2187 | struct task_struct *thread; |
| 2188 | struct bnx2fc_work *work, *tmp; |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2189 | |
| 2190 | BNX2FC_MISC_DBG("destroying io thread for CPU %d\n", cpu); |
| 2191 | |
| 2192 | /* Prevent any new work from being queued for this CPU */ |
| 2193 | p = &per_cpu(bnx2fc_percpu, cpu); |
| 2194 | spin_lock_bh(&p->fp_work_lock); |
| 2195 | thread = p->iothread; |
| 2196 | p->iothread = NULL; |
| 2197 | |
| 2198 | |
| 2199 | /* Free all work in the list */ |
Bhanu Prakash Gollapudi | 3224876 | 2011-08-04 17:38:36 -0700 | [diff] [blame] | 2200 | list_for_each_entry_safe(work, tmp, &p->work_list, list) { |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2201 | list_del_init(&work->list); |
| 2202 | bnx2fc_process_cq_compl(work->tgt, work->wqe); |
| 2203 | kfree(work); |
| 2204 | } |
| 2205 | |
| 2206 | spin_unlock_bh(&p->fp_work_lock); |
| 2207 | |
| 2208 | if (thread) |
| 2209 | kthread_stop(thread); |
| 2210 | } |
| 2211 | |
| 2212 | /** |
| 2213 | * bnx2fc_cpu_callback - Handler for CPU hotplug events |
| 2214 | * |
| 2215 | * @nfb: The callback data block |
| 2216 | * @action: The event triggering the callback |
| 2217 | * @hcpu: The index of the CPU that the event is for |
| 2218 | * |
| 2219 | * This creates or destroys per-CPU data for fcoe |
| 2220 | * |
| 2221 | * Returns NOTIFY_OK always. |
| 2222 | */ |
| 2223 | static int bnx2fc_cpu_callback(struct notifier_block *nfb, |
| 2224 | unsigned long action, void *hcpu) |
| 2225 | { |
| 2226 | unsigned cpu = (unsigned long)hcpu; |
| 2227 | |
| 2228 | switch (action) { |
| 2229 | case CPU_ONLINE: |
| 2230 | case CPU_ONLINE_FROZEN: |
| 2231 | printk(PFX "CPU %x online: Create Rx thread\n", cpu); |
| 2232 | bnx2fc_percpu_thread_create(cpu); |
| 2233 | break; |
| 2234 | case CPU_DEAD: |
| 2235 | case CPU_DEAD_FROZEN: |
| 2236 | printk(PFX "CPU %x offline: Remove Rx thread\n", cpu); |
| 2237 | bnx2fc_percpu_thread_destroy(cpu); |
| 2238 | break; |
| 2239 | default: |
| 2240 | break; |
| 2241 | } |
| 2242 | return NOTIFY_OK; |
| 2243 | } |
| 2244 | |
| 2245 | /** |
| 2246 | * bnx2fc_mod_init - module init entry point |
| 2247 | * |
| 2248 | * Initialize driver wide global data structures, and register |
| 2249 | * with cnic module |
| 2250 | **/ |
| 2251 | static int __init bnx2fc_mod_init(void) |
| 2252 | { |
| 2253 | struct fcoe_percpu_s *bg; |
| 2254 | struct task_struct *l2_thread; |
| 2255 | int rc = 0; |
| 2256 | unsigned int cpu = 0; |
| 2257 | struct bnx2fc_percpu_s *p; |
| 2258 | |
| 2259 | printk(KERN_INFO PFX "%s", version); |
| 2260 | |
| 2261 | /* register as a fcoe transport */ |
| 2262 | rc = fcoe_transport_attach(&bnx2fc_transport); |
| 2263 | if (rc) { |
| 2264 | printk(KERN_ERR "failed to register an fcoe transport, check " |
| 2265 | "if libfcoe is loaded\n"); |
| 2266 | goto out; |
| 2267 | } |
| 2268 | |
| 2269 | INIT_LIST_HEAD(&adapter_list); |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2270 | INIT_LIST_HEAD(&if_list); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2271 | mutex_init(&bnx2fc_dev_lock); |
| 2272 | adapter_count = 0; |
| 2273 | |
| 2274 | /* Attach FC transport template */ |
| 2275 | rc = bnx2fc_attach_transport(); |
| 2276 | if (rc) |
| 2277 | goto detach_ft; |
| 2278 | |
| 2279 | bnx2fc_wq = alloc_workqueue("bnx2fc", 0, 0); |
| 2280 | if (!bnx2fc_wq) { |
| 2281 | rc = -ENOMEM; |
| 2282 | goto release_bt; |
| 2283 | } |
| 2284 | |
| 2285 | bg = &bnx2fc_global; |
| 2286 | skb_queue_head_init(&bg->fcoe_rx_list); |
| 2287 | l2_thread = kthread_create(bnx2fc_l2_rcv_thread, |
| 2288 | (void *)bg, |
| 2289 | "bnx2fc_l2_thread"); |
| 2290 | if (IS_ERR(l2_thread)) { |
| 2291 | rc = PTR_ERR(l2_thread); |
| 2292 | goto free_wq; |
| 2293 | } |
| 2294 | wake_up_process(l2_thread); |
| 2295 | spin_lock_bh(&bg->fcoe_rx_list.lock); |
| 2296 | bg->thread = l2_thread; |
| 2297 | spin_unlock_bh(&bg->fcoe_rx_list.lock); |
| 2298 | |
| 2299 | for_each_possible_cpu(cpu) { |
| 2300 | p = &per_cpu(bnx2fc_percpu, cpu); |
| 2301 | INIT_LIST_HEAD(&p->work_list); |
| 2302 | spin_lock_init(&p->fp_work_lock); |
| 2303 | } |
| 2304 | |
| 2305 | for_each_online_cpu(cpu) { |
| 2306 | bnx2fc_percpu_thread_create(cpu); |
| 2307 | } |
| 2308 | |
| 2309 | /* Initialize per CPU interrupt thread */ |
| 2310 | register_hotcpu_notifier(&bnx2fc_cpu_notifier); |
| 2311 | |
| 2312 | cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb); |
| 2313 | |
| 2314 | return 0; |
| 2315 | |
| 2316 | free_wq: |
| 2317 | destroy_workqueue(bnx2fc_wq); |
| 2318 | release_bt: |
| 2319 | bnx2fc_release_transport(); |
| 2320 | detach_ft: |
| 2321 | fcoe_transport_detach(&bnx2fc_transport); |
| 2322 | out: |
| 2323 | return rc; |
| 2324 | } |
| 2325 | |
| 2326 | static void __exit bnx2fc_mod_exit(void) |
| 2327 | { |
| 2328 | LIST_HEAD(to_be_deleted); |
| 2329 | struct bnx2fc_hba *hba, *next; |
| 2330 | struct fcoe_percpu_s *bg; |
| 2331 | struct task_struct *l2_thread; |
| 2332 | struct sk_buff *skb; |
| 2333 | unsigned int cpu = 0; |
| 2334 | |
| 2335 | /* |
| 2336 | * NOTE: Since cnic calls register_driver routine rtnl_lock, |
| 2337 | * it will have higher precedence than bnx2fc_dev_lock. |
| 2338 | * unregister_device() cannot be called with bnx2fc_dev_lock |
| 2339 | * held. |
| 2340 | */ |
| 2341 | mutex_lock(&bnx2fc_dev_lock); |
| 2342 | list_splice(&adapter_list, &to_be_deleted); |
| 2343 | INIT_LIST_HEAD(&adapter_list); |
| 2344 | adapter_count = 0; |
| 2345 | mutex_unlock(&bnx2fc_dev_lock); |
| 2346 | |
| 2347 | /* Unregister with cnic */ |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2348 | list_for_each_entry_safe(hba, next, &to_be_deleted, list) { |
| 2349 | list_del_init(&hba->list); |
| 2350 | printk(KERN_ERR PFX "MOD_EXIT:destroy hba = 0x%p\n", |
| 2351 | hba); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2352 | bnx2fc_ulp_stop(hba); |
| 2353 | /* unregister cnic device */ |
| 2354 | if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, |
| 2355 | &hba->reg_with_cnic)) |
Bhanu Prakash Gollapudi | aea71a0 | 2011-07-26 14:51:39 -0700 | [diff] [blame] | 2356 | hba->cnic->unregister_device(hba->cnic, |
| 2357 | CNIC_ULP_FCOE); |
| 2358 | bnx2fc_hba_destroy(hba); |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2359 | } |
| 2360 | cnic_unregister_driver(CNIC_ULP_FCOE); |
| 2361 | |
| 2362 | /* Destroy global thread */ |
| 2363 | bg = &bnx2fc_global; |
| 2364 | spin_lock_bh(&bg->fcoe_rx_list.lock); |
| 2365 | l2_thread = bg->thread; |
| 2366 | bg->thread = NULL; |
| 2367 | while ((skb = __skb_dequeue(&bg->fcoe_rx_list)) != NULL) |
| 2368 | kfree_skb(skb); |
| 2369 | |
| 2370 | spin_unlock_bh(&bg->fcoe_rx_list.lock); |
| 2371 | |
| 2372 | if (l2_thread) |
| 2373 | kthread_stop(l2_thread); |
| 2374 | |
| 2375 | unregister_hotcpu_notifier(&bnx2fc_cpu_notifier); |
| 2376 | |
| 2377 | /* Destroy per cpu threads */ |
| 2378 | for_each_online_cpu(cpu) { |
| 2379 | bnx2fc_percpu_thread_destroy(cpu); |
| 2380 | } |
| 2381 | |
| 2382 | destroy_workqueue(bnx2fc_wq); |
| 2383 | /* |
| 2384 | * detach from scsi transport |
| 2385 | * must happen after all destroys are done |
| 2386 | */ |
| 2387 | bnx2fc_release_transport(); |
| 2388 | |
| 2389 | /* detach from fcoe transport */ |
| 2390 | fcoe_transport_detach(&bnx2fc_transport); |
| 2391 | } |
| 2392 | |
| 2393 | module_init(bnx2fc_mod_init); |
| 2394 | module_exit(bnx2fc_mod_exit); |
| 2395 | |
| 2396 | static struct fc_function_template bnx2fc_transport_function = { |
| 2397 | .show_host_node_name = 1, |
| 2398 | .show_host_port_name = 1, |
| 2399 | .show_host_supported_classes = 1, |
| 2400 | .show_host_supported_fc4s = 1, |
| 2401 | .show_host_active_fc4s = 1, |
| 2402 | .show_host_maxframe_size = 1, |
| 2403 | |
| 2404 | .show_host_port_id = 1, |
| 2405 | .show_host_supported_speeds = 1, |
| 2406 | .get_host_speed = fc_get_host_speed, |
| 2407 | .show_host_speed = 1, |
| 2408 | .show_host_port_type = 1, |
| 2409 | .get_host_port_state = fc_get_host_port_state, |
| 2410 | .show_host_port_state = 1, |
| 2411 | .show_host_symbolic_name = 1, |
| 2412 | |
| 2413 | .dd_fcrport_size = (sizeof(struct fc_rport_libfc_priv) + |
| 2414 | sizeof(struct bnx2fc_rport)), |
| 2415 | .show_rport_maxframe_size = 1, |
| 2416 | .show_rport_supported_classes = 1, |
| 2417 | |
| 2418 | .show_host_fabric_name = 1, |
| 2419 | .show_starget_node_name = 1, |
| 2420 | .show_starget_port_name = 1, |
| 2421 | .show_starget_port_id = 1, |
| 2422 | .set_rport_dev_loss_tmo = fc_set_rport_loss_tmo, |
| 2423 | .show_rport_dev_loss_tmo = 1, |
| 2424 | .get_fc_host_stats = bnx2fc_get_host_stats, |
| 2425 | |
| 2426 | .issue_fc_host_lip = bnx2fc_fcoe_reset, |
| 2427 | |
| 2428 | .terminate_rport_io = fc_rport_terminate_io, |
| 2429 | |
| 2430 | .vport_create = bnx2fc_vport_create, |
| 2431 | .vport_delete = bnx2fc_vport_destroy, |
| 2432 | .vport_disable = bnx2fc_vport_disable, |
Bhanu Prakash Gollapudi | e9a5289c | 2011-08-04 17:38:37 -0700 | [diff] [blame] | 2433 | .bsg_request = fc_lport_bsg_request, |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2434 | }; |
| 2435 | |
| 2436 | static struct fc_function_template bnx2fc_vport_xport_function = { |
| 2437 | .show_host_node_name = 1, |
| 2438 | .show_host_port_name = 1, |
| 2439 | .show_host_supported_classes = 1, |
| 2440 | .show_host_supported_fc4s = 1, |
| 2441 | .show_host_active_fc4s = 1, |
| 2442 | .show_host_maxframe_size = 1, |
| 2443 | |
| 2444 | .show_host_port_id = 1, |
| 2445 | .show_host_supported_speeds = 1, |
| 2446 | .get_host_speed = fc_get_host_speed, |
| 2447 | .show_host_speed = 1, |
| 2448 | .show_host_port_type = 1, |
| 2449 | .get_host_port_state = fc_get_host_port_state, |
| 2450 | .show_host_port_state = 1, |
| 2451 | .show_host_symbolic_name = 1, |
| 2452 | |
| 2453 | .dd_fcrport_size = (sizeof(struct fc_rport_libfc_priv) + |
| 2454 | sizeof(struct bnx2fc_rport)), |
| 2455 | .show_rport_maxframe_size = 1, |
| 2456 | .show_rport_supported_classes = 1, |
| 2457 | |
| 2458 | .show_host_fabric_name = 1, |
| 2459 | .show_starget_node_name = 1, |
| 2460 | .show_starget_port_name = 1, |
| 2461 | .show_starget_port_id = 1, |
| 2462 | .set_rport_dev_loss_tmo = fc_set_rport_loss_tmo, |
| 2463 | .show_rport_dev_loss_tmo = 1, |
| 2464 | .get_fc_host_stats = fc_get_host_stats, |
| 2465 | .issue_fc_host_lip = bnx2fc_fcoe_reset, |
| 2466 | .terminate_rport_io = fc_rport_terminate_io, |
Bhanu Prakash Gollapudi | e9a5289c | 2011-08-04 17:38:37 -0700 | [diff] [blame] | 2467 | .bsg_request = fc_lport_bsg_request, |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2468 | }; |
| 2469 | |
| 2470 | /** |
| 2471 | * scsi_host_template structure used while registering with SCSI-ml |
| 2472 | */ |
| 2473 | static struct scsi_host_template bnx2fc_shost_template = { |
| 2474 | .module = THIS_MODULE, |
| 2475 | .name = "Broadcom Offload FCoE Initiator", |
| 2476 | .queuecommand = bnx2fc_queuecommand, |
| 2477 | .eh_abort_handler = bnx2fc_eh_abort, /* abts */ |
| 2478 | .eh_device_reset_handler = bnx2fc_eh_device_reset, /* lun reset */ |
| 2479 | .eh_target_reset_handler = bnx2fc_eh_target_reset, /* tgt reset */ |
| 2480 | .eh_host_reset_handler = fc_eh_host_reset, |
| 2481 | .slave_alloc = fc_slave_alloc, |
| 2482 | .change_queue_depth = fc_change_queue_depth, |
| 2483 | .change_queue_type = fc_change_queue_type, |
| 2484 | .this_id = -1, |
| 2485 | .cmd_per_lun = 3, |
Bhanu Gollapudi | 0ea5c27 | 2011-03-17 17:13:29 -0700 | [diff] [blame] | 2486 | .can_queue = BNX2FC_CAN_QUEUE, |
Bhanu Gollapudi | 853e2bd | 2011-02-04 12:10:34 -0800 | [diff] [blame] | 2487 | .use_clustering = ENABLE_CLUSTERING, |
| 2488 | .sg_tablesize = BNX2FC_MAX_BDS_PER_CMD, |
| 2489 | .max_sectors = 512, |
| 2490 | }; |
| 2491 | |
| 2492 | static struct libfc_function_template bnx2fc_libfc_fcn_templ = { |
| 2493 | .frame_send = bnx2fc_xmit, |
| 2494 | .elsct_send = bnx2fc_elsct_send, |
| 2495 | .fcp_abort_io = bnx2fc_abort_io, |
| 2496 | .fcp_cleanup = bnx2fc_cleanup, |
| 2497 | .rport_event_callback = bnx2fc_rport_event_handler, |
| 2498 | }; |
| 2499 | |
| 2500 | /** |
| 2501 | * bnx2fc_cnic_cb - global template of bnx2fc - cnic driver interface |
| 2502 | * structure carrying callback function pointers |
| 2503 | */ |
| 2504 | static struct cnic_ulp_ops bnx2fc_cnic_cb = { |
| 2505 | .owner = THIS_MODULE, |
| 2506 | .cnic_init = bnx2fc_ulp_init, |
| 2507 | .cnic_exit = bnx2fc_ulp_exit, |
| 2508 | .cnic_start = bnx2fc_ulp_start, |
| 2509 | .cnic_stop = bnx2fc_ulp_stop, |
| 2510 | .indicate_kcqes = bnx2fc_indicate_kcqe, |
| 2511 | .indicate_netevent = bnx2fc_indicate_netevent, |
| 2512 | }; |