Lines Matching +full:sub +full:- +full:frame
1 // SPDX-License-Identifier: GPL-2.0-only
13 * fnic_fcoe_reset_vlans - Free up the list of discovered vlans
21 spin_lock_irqsave(&fnic->vlans_lock, flags); in fnic_fcoe_reset_vlans()
22 if (!list_empty(&fnic->vlan_list)) { in fnic_fcoe_reset_vlans()
23 list_for_each_entry_safe(vlan, next, &fnic->vlan_list, list) { in fnic_fcoe_reset_vlans()
24 list_del(&vlan->list); in fnic_fcoe_reset_vlans()
29 spin_unlock_irqrestore(&fnic->vlans_lock, flags); in fnic_fcoe_reset_vlans()
30 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_reset_vlans()
35 * fnic_fcoe_send_vlan_req - Send FIP vlan request to all FCFs MAC
40 uint8_t *frame; in fnic_fcoe_send_vlan_req() local
41 struct fnic_iport_s *iport = &fnic->iport; in fnic_fcoe_send_vlan_req()
42 struct fnic_stats *fnic_stats = &fnic->fnic_stats; in fnic_fcoe_send_vlan_req()
47 frame = fdls_alloc_frame(iport); in fnic_fcoe_send_vlan_req()
48 if (frame == NULL) { in fnic_fcoe_send_vlan_req()
49 FNIC_FIP_DBG(KERN_ERR, fnic->host, fnic->fnic_num, in fnic_fcoe_send_vlan_req()
50 "Failed to allocate frame to send VLAN req"); in fnic_fcoe_send_vlan_req()
56 fnic->set_vlan(fnic, 0); in fnic_fcoe_send_vlan_req()
57 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_send_vlan_req()
60 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_send_vlan_req()
61 "got MAC 0x%x:%x:%x:%x:%x:%x\n", iport->hwmac[0], in fnic_fcoe_send_vlan_req()
62 iport->hwmac[1], iport->hwmac[2], iport->hwmac[3], in fnic_fcoe_send_vlan_req()
63 iport->hwmac[4], iport->hwmac[5]); in fnic_fcoe_send_vlan_req()
65 pvlan_req = (struct fip_vlan_req *) frame; in fnic_fcoe_send_vlan_req()
77 memcpy(pvlan_req->eth.h_source, iport->hwmac, ETH_ALEN); in fnic_fcoe_send_vlan_req()
78 memcpy(pvlan_req->mac_desc.fd_mac, iport->hwmac, ETH_ALEN); in fnic_fcoe_send_vlan_req()
80 atomic64_inc(&fnic_stats->vlan_stats.vlan_disc_reqs); in fnic_fcoe_send_vlan_req()
82 iport->fip.state = FDLS_FIP_VLAN_DISCOVERY_STARTED; in fnic_fcoe_send_vlan_req()
84 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_send_vlan_req()
86 fnic_send_fip_frame(iport, frame, frame_size); in fnic_fcoe_send_vlan_req()
89 mod_timer(&fnic->retry_fip_timer, round_jiffies(vlan_tov)); in fnic_fcoe_send_vlan_req()
90 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_send_vlan_req()
95 * fnic_fcoe_process_vlan_resp - Processes the vlan response from one FCF and
98 * @fiph: Received FIP frame
106 struct fnic_stats *fnic_stats = &fnic->fnic_stats; in fnic_fcoe_process_vlan_resp()
114 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_vlan_resp()
117 desc_len = be16_to_cpu(vlan_notif->fip.fip_dl_len); in fnic_fcoe_process_vlan_resp()
118 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_vlan_resp()
121 spin_lock_irqsave(&fnic->vlans_lock, flags); in fnic_fcoe_process_vlan_resp()
126 (struct fip_vlan_desc *)(((char *)vlan_notif->vlans_desc) in fnic_fcoe_process_vlan_resp()
129 if (vlan_desc->fd_desc.fip_dtype == FIP_DT_VLAN) { in fnic_fcoe_process_vlan_resp()
130 if (vlan_desc->fd_desc.fip_dlen != 1) { in fnic_fcoe_process_vlan_resp()
131 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_process_vlan_resp()
132 fnic->fnic_num, in fnic_fcoe_process_vlan_resp()
134 vlan_desc->fd_desc.fip_dlen); in fnic_fcoe_process_vlan_resp()
138 vid = be16_to_cpu(vlan_desc->fd_vlan); in fnic_fcoe_process_vlan_resp()
139 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_process_vlan_resp()
140 fnic->fnic_num, in fnic_fcoe_process_vlan_resp()
146 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_process_vlan_resp()
147 fnic->fnic_num, in fnic_fcoe_process_vlan_resp()
149 spin_unlock_irqrestore(&fnic->vlans_lock, in fnic_fcoe_process_vlan_resp()
153 vlan->vid = vid & 0x0fff; in fnic_fcoe_process_vlan_resp()
154 vlan->state = FIP_VLAN_AVAIL; in fnic_fcoe_process_vlan_resp()
155 list_add_tail(&vlan->list, &fnic->vlan_list); in fnic_fcoe_process_vlan_resp()
158 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_process_vlan_resp()
159 fnic->fnic_num, in fnic_fcoe_process_vlan_resp()
161 vlan_desc->fd_desc.fip_dtype); in fnic_fcoe_process_vlan_resp()
166 cur_desc += vlan_desc->fd_desc.fip_dlen; in fnic_fcoe_process_vlan_resp()
167 desc_len -= vlan_desc->fd_desc.fip_dlen; in fnic_fcoe_process_vlan_resp()
172 atomic64_inc(&fnic_stats->vlan_stats.resp_withno_vlanID); in fnic_fcoe_process_vlan_resp()
173 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_vlan_resp()
178 spin_unlock_irqrestore(&fnic->vlans_lock, flags); in fnic_fcoe_process_vlan_resp()
185 * fnic_fcoe_start_fcf_discovery - Start FIP FCF discovery in a selected vlan
190 uint8_t *frame; in fnic_fcoe_start_fcf_discovery() local
191 struct fnic_iport_s *iport = &fnic->iport; in fnic_fcoe_start_fcf_discovery()
196 frame = fdls_alloc_frame(iport); in fnic_fcoe_start_fcf_discovery()
197 if (frame == NULL) { in fnic_fcoe_start_fcf_discovery()
198 FNIC_FIP_DBG(KERN_ERR, fnic->host, fnic->fnic_num, in fnic_fcoe_start_fcf_discovery()
199 "Failed to allocate frame to start FCF discovery"); in fnic_fcoe_start_fcf_discovery()
203 memset(iport->selected_fcf.fcf_mac, 0, ETH_ALEN); in fnic_fcoe_start_fcf_discovery()
205 pdisc_sol = (struct fip_discovery *) frame; in fnic_fcoe_start_fcf_discovery()
219 memcpy(pdisc_sol->eth.h_source, iport->hwmac, ETH_ALEN); in fnic_fcoe_start_fcf_discovery()
220 memcpy(pdisc_sol->mac_desc.fd_mac, iport->hwmac, ETH_ALEN); in fnic_fcoe_start_fcf_discovery()
221 iport->selected_fcf.fcf_priority = 0xFF; in fnic_fcoe_start_fcf_discovery()
223 FNIC_STD_SET_NODE_NAME(&pdisc_sol->name_desc.fd_wwn, iport->wwnn); in fnic_fcoe_start_fcf_discovery()
225 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_start_fcf_discovery()
227 fnic_send_fip_frame(iport, frame, frame_size); in fnic_fcoe_start_fcf_discovery()
229 iport->fip.state = FDLS_FIP_FCF_DISCOVERY_STARTED; in fnic_fcoe_start_fcf_discovery()
232 mod_timer(&fnic->retry_fip_timer, round_jiffies(fcs_tov)); in fnic_fcoe_start_fcf_discovery()
236 * fnic_fcoe_fip_discovery_resp - Processes FCF advertisements.
238 * @fiph: Received frame
241 * solicited - Sent in response of a discover FCF FIP request
245 * unsolicited - Sent periodically by the FCF for keep alive.
251 struct fnic_iport_s *iport = &fnic->iport; in fnic_fcoe_fip_discovery_resp()
257 switch (iport->fip.state) { in fnic_fcoe_fip_discovery_resp()
259 if (be16_to_cpu(disc_adv->fip.fip_flags) & FIP_FL_SOL) { in fnic_fcoe_fip_discovery_resp()
260 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_fip_discovery_resp()
261 fnic->fnic_num, in fnic_fcoe_fip_discovery_resp()
264 if ((disc_adv->prio_desc.fd_pri < in fnic_fcoe_fip_discovery_resp()
265 iport->selected_fcf.fcf_priority) in fnic_fcoe_fip_discovery_resp()
266 && (be16_to_cpu(disc_adv->fip.fip_flags) & FIP_FL_AVAIL)) { in fnic_fcoe_fip_discovery_resp()
268 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_fip_discovery_resp()
269 fnic->fnic_num, in fnic_fcoe_fip_discovery_resp()
271 memcpy(iport->selected_fcf.fcf_mac, in fnic_fcoe_fip_discovery_resp()
272 disc_adv->mac_desc.fd_mac, ETH_ALEN); in fnic_fcoe_fip_discovery_resp()
273 iport->selected_fcf.fcf_priority = in fnic_fcoe_fip_discovery_resp()
274 disc_adv->prio_desc.fd_pri; in fnic_fcoe_fip_discovery_resp()
275 iport->selected_fcf.fka_adv_period = in fnic_fcoe_fip_discovery_resp()
276 be32_to_cpu(disc_adv->fka_adv_desc.fd_fka_period); in fnic_fcoe_fip_discovery_resp()
277 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_fip_discovery_resp()
278 fnic->fnic_num, "adv time %d", in fnic_fcoe_fip_discovery_resp()
279 iport->selected_fcf.fka_adv_period); in fnic_fcoe_fip_discovery_resp()
280 iport->selected_fcf.ka_disabled = in fnic_fcoe_fip_discovery_resp()
281 (disc_adv->fka_adv_desc.fd_flags & 1); in fnic_fcoe_fip_discovery_resp()
287 if (!(be16_to_cpu(disc_adv->fip.fip_flags) & FIP_FL_SOL)) { in fnic_fcoe_fip_discovery_resp()
290 (iport->selected_fcf.fcf_mac, in fnic_fcoe_fip_discovery_resp()
291 disc_adv->mac_desc.fd_mac, ETH_ALEN) == 0) { in fnic_fcoe_fip_discovery_resp()
292 if (iport->selected_fcf.fka_adv_period != in fnic_fcoe_fip_discovery_resp()
293 be32_to_cpu(disc_adv->fka_adv_desc.fd_fka_period)) { in fnic_fcoe_fip_discovery_resp()
294 iport->selected_fcf.fka_adv_period = in fnic_fcoe_fip_discovery_resp()
295 be32_to_cpu(disc_adv->fka_adv_desc.fd_fka_period); in fnic_fcoe_fip_discovery_resp()
297 fnic->host, in fnic_fcoe_fip_discovery_resp()
298 fnic->fnic_num, in fnic_fcoe_fip_discovery_resp()
300 iport->selected_fcf.fka_adv_period); in fnic_fcoe_fip_discovery_resp()
304 (iport->selected_fcf.ka_disabled == 1) in fnic_fcoe_fip_discovery_resp()
305 && ((disc_adv->fka_adv_desc.fd_flags & 1) == in fnic_fcoe_fip_discovery_resp()
308 iport->selected_fcf.ka_disabled = in fnic_fcoe_fip_discovery_resp()
309 (disc_adv->fka_adv_desc.fd_flags & 1); in fnic_fcoe_fip_discovery_resp()
310 if (!((iport->selected_fcf.ka_disabled) in fnic_fcoe_fip_discovery_resp()
311 || (iport->selected_fcf.fka_adv_period == in fnic_fcoe_fip_discovery_resp()
317 msecs_to_jiffies(iport->selected_fcf.fka_adv_period); in fnic_fcoe_fip_discovery_resp()
318 mod_timer(&fnic->fcs_ka_timer, in fnic_fcoe_fip_discovery_resp()
321 if (timer_pending(&fnic->fcs_ka_timer)) in fnic_fcoe_fip_discovery_resp()
322 del_timer_sync(&fnic->fcs_ka_timer); in fnic_fcoe_fip_discovery_resp()
326 if (iport->selected_fcf.fka_adv_period != 0) { in fnic_fcoe_fip_discovery_resp()
330 iport->selected_fcf.fka_adv_period); in fnic_fcoe_fip_discovery_resp()
331 mod_timer(&fnic->enode_ka_timer, in fnic_fcoe_fip_discovery_resp()
338 mod_timer(&fnic->vn_ka_timer, in fnic_fcoe_fip_discovery_resp()
351 * fnic_fcoe_start_flogi - Send FIP FLOGI to the selected FCF
356 uint8_t *frame; in fnic_fcoe_start_flogi() local
357 struct fnic_iport_s *iport = &fnic->iport; in fnic_fcoe_start_flogi()
363 frame = fdls_alloc_frame(iport); in fnic_fcoe_start_flogi()
364 if (frame == NULL) { in fnic_fcoe_start_flogi()
365 FNIC_FIP_DBG(KERN_ERR, fnic->host, fnic->fnic_num, in fnic_fcoe_start_flogi()
366 "Failed to allocate frame to start FIP FLOGI"); in fnic_fcoe_start_flogi()
370 pflogi_req = (struct fip_flogi *) frame; in fnic_fcoe_start_flogi()
410 memcpy(pflogi_req->eth.h_source, iport->hwmac, ETH_ALEN); in fnic_fcoe_start_flogi()
411 if (iport->usefip) in fnic_fcoe_start_flogi()
412 memcpy(pflogi_req->eth.h_dest, iport->selected_fcf.fcf_mac, in fnic_fcoe_start_flogi()
416 &iport->active_oxid_fabric_req); in fnic_fcoe_start_flogi()
418 FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_start_flogi()
420 mempool_free(frame, fnic->frame_pool); in fnic_fcoe_start_flogi()
423 FNIC_STD_SET_OX_ID(pflogi_req->flogi_desc.flogi.fchdr, oxid); in fnic_fcoe_start_flogi()
425 FNIC_STD_SET_NPORT_NAME(&pflogi_req->flogi_desc.flogi.els.fl_wwpn, in fnic_fcoe_start_flogi()
426 iport->wwpn); in fnic_fcoe_start_flogi()
427 FNIC_STD_SET_NODE_NAME(&pflogi_req->flogi_desc.flogi.els.fl_wwnn, in fnic_fcoe_start_flogi()
428 iport->wwnn); in fnic_fcoe_start_flogi()
430 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_start_flogi()
432 fnic_send_fip_frame(iport, frame, frame_size); in fnic_fcoe_start_flogi()
433 iport->fip.flogi_retry++; in fnic_fcoe_start_flogi()
435 iport->fip.state = FDLS_FIP_FLOGI_STARTED; in fnic_fcoe_start_flogi()
436 flogi_tov = jiffies + msecs_to_jiffies(fnic->config.flogi_timeout); in fnic_fcoe_start_flogi()
437 mod_timer(&fnic->retry_fip_timer, round_jiffies(flogi_tov)); in fnic_fcoe_start_flogi()
441 * fnic_fcoe_process_flogi_resp - Processes FLOGI response from FCF.
443 * @fiph: Received frame
450 struct fnic_iport_s *iport = &fnic->iport; in fnic_fcoe_process_flogi_resp()
457 struct fnic_stats *fnic_stats = &fnic->fnic_stats; in fnic_fcoe_process_flogi_resp()
458 struct fc_frame_header *fchdr = &flogi_rsp->rsp_desc.flogi.fchdr; in fnic_fcoe_process_flogi_resp()
460 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_flogi_resp()
462 desc_len = be16_to_cpu(flogi_rsp->fip.fip_dl_len); in fnic_fcoe_process_flogi_resp()
464 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_flogi_resp()
465 "Invalid Descriptor List len (%x). Dropping frame\n", in fnic_fcoe_process_flogi_resp()
470 if (!((flogi_rsp->rsp_desc.fd_desc.fip_dtype == 7) in fnic_fcoe_process_flogi_resp()
471 && (flogi_rsp->rsp_desc.fd_desc.fip_dlen == 36)) in fnic_fcoe_process_flogi_resp()
472 || !((flogi_rsp->mac_desc.fd_desc.fip_dtype == 2) in fnic_fcoe_process_flogi_resp()
473 && (flogi_rsp->mac_desc.fd_desc.fip_dlen == 2))) { in fnic_fcoe_process_flogi_resp()
474 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_flogi_resp()
475 "Dropping frame invalid type and len mix\n"); in fnic_fcoe_process_flogi_resp()
481 s_id = ntoh24(fchdr->fh_s_id); in fnic_fcoe_process_flogi_resp()
482 if ((fchdr->fh_f_ctl[0] != 0x98) in fnic_fcoe_process_flogi_resp()
483 || (fchdr->fh_r_ctl != 0x23) in fnic_fcoe_process_flogi_resp()
486 || (fchdr->fh_type != 0x01)) { in fnic_fcoe_process_flogi_resp()
487 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_flogi_resp()
488 "Dropping invalid frame: s_id %x F %x R %x t %x OX_ID %x\n", in fnic_fcoe_process_flogi_resp()
489 s_id, fchdr->fh_f_ctl[0], fchdr->fh_r_ctl, in fnic_fcoe_process_flogi_resp()
490 fchdr->fh_type, FNIC_STD_GET_OX_ID(fchdr)); in fnic_fcoe_process_flogi_resp()
494 if (iport->fip.state == FDLS_FIP_FLOGI_STARTED) { in fnic_fcoe_process_flogi_resp()
495 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_flogi_resp()
499 fdls_free_oxid(iport, oxid, &iport->active_oxid_fabric_req); in fnic_fcoe_process_flogi_resp()
500 del_timer_sync(&fnic->retry_fip_timer); in fnic_fcoe_process_flogi_resp()
502 if ((be16_to_cpu(flogi_rsp->fip.fip_dl_len) == FIP_FLOGI_LEN) in fnic_fcoe_process_flogi_resp()
503 && (flogi_rsp->rsp_desc.flogi.els.fl_cmd == ELS_LS_ACC)) { in fnic_fcoe_process_flogi_resp()
505 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_process_flogi_resp()
506 fnic->fnic_num, in fnic_fcoe_process_flogi_resp()
508 memcpy(iport->fpma, flogi_rsp->mac_desc.fd_mac, ETH_ALEN); in fnic_fcoe_process_flogi_resp()
509 iport->fcid = in fnic_fcoe_process_flogi_resp()
510 ntoh24(flogi_rsp->rsp_desc.flogi.fchdr.fh_d_id); in fnic_fcoe_process_flogi_resp()
512 iport->r_a_tov = in fnic_fcoe_process_flogi_resp()
513 be32_to_cpu(flogi_rsp->rsp_desc.flogi.els.fl_csp.sp_r_a_tov); in fnic_fcoe_process_flogi_resp()
514 iport->e_d_tov = in fnic_fcoe_process_flogi_resp()
515 be32_to_cpu(flogi_rsp->rsp_desc.flogi.els.fl_csp.sp_e_d_tov); in fnic_fcoe_process_flogi_resp()
516 memcpy(fnic->iport.fcfmac, iport->selected_fcf.fcf_mac, in fnic_fcoe_process_flogi_resp()
518 vnic_dev_add_addr(fnic->vdev, flogi_rsp->mac_desc.fd_mac); in fnic_fcoe_process_flogi_resp()
520 if (fnic_fdls_register_portid(iport, iport->fcid, NULL) in fnic_fcoe_process_flogi_resp()
522 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_process_flogi_resp()
523 fnic->fnic_num, in fnic_fcoe_process_flogi_resp()
529 iport->fip.state = FDLS_FIP_FLOGI_COMPLETE; in fnic_fcoe_process_flogi_resp()
530 iport->state = FNIC_IPORT_STATE_FABRIC_DISC; in fnic_fcoe_process_flogi_resp()
531 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_process_flogi_resp()
532 fnic->fnic_num, "iport->state:%d\n", in fnic_fcoe_process_flogi_resp()
533 iport->state); in fnic_fcoe_process_flogi_resp()
535 if (!((iport->selected_fcf.ka_disabled) in fnic_fcoe_process_flogi_resp()
536 || (iport->selected_fcf.fka_adv_period == 0))) { in fnic_fcoe_process_flogi_resp()
541 msecs_to_jiffies(iport->selected_fcf.fka_adv_period); in fnic_fcoe_process_flogi_resp()
542 mod_timer(&fnic->enode_ka_timer, in fnic_fcoe_process_flogi_resp()
548 mod_timer(&fnic->vn_ka_timer, in fnic_fcoe_process_flogi_resp()
554 * If there's FLOGI rejects - clear all in fnic_fcoe_process_flogi_resp()
557 atomic64_inc(&fnic_stats->vlan_stats.flogi_rejects); in fnic_fcoe_process_flogi_resp()
561 iport->fip.state = FDLS_FIP_VLAN_DISCOVERY_STARTED; in fnic_fcoe_process_flogi_resp()
567 * fnic_common_fip_cleanup - Clean up FCF info and timers in case of
574 struct fnic_iport_s *iport = &fnic->iport; in fnic_common_fip_cleanup()
576 if (!iport->usefip) in fnic_common_fip_cleanup()
578 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_common_fip_cleanup()
581 iport->fip.state = FDLS_FIP_INIT; in fnic_common_fip_cleanup()
583 del_timer_sync(&fnic->retry_fip_timer); in fnic_common_fip_cleanup()
584 del_timer_sync(&fnic->fcs_ka_timer); in fnic_common_fip_cleanup()
585 del_timer_sync(&fnic->enode_ka_timer); in fnic_common_fip_cleanup()
586 del_timer_sync(&fnic->vn_ka_timer); in fnic_common_fip_cleanup()
588 if (!is_zero_ether_addr(iport->fpma)) in fnic_common_fip_cleanup()
589 vnic_dev_del_addr(fnic->vdev, iport->fpma); in fnic_common_fip_cleanup()
591 memset(iport->fpma, 0, ETH_ALEN); in fnic_common_fip_cleanup()
592 iport->fcid = 0; in fnic_common_fip_cleanup()
593 iport->r_a_tov = 0; in fnic_common_fip_cleanup()
594 iport->e_d_tov = 0; in fnic_common_fip_cleanup()
595 memset(fnic->iport.fcfmac, 0, ETH_ALEN); in fnic_common_fip_cleanup()
596 memset(iport->selected_fcf.fcf_mac, 0, ETH_ALEN); in fnic_common_fip_cleanup()
597 iport->selected_fcf.fcf_priority = 0; in fnic_common_fip_cleanup()
598 iport->selected_fcf.fka_adv_period = 0; in fnic_common_fip_cleanup()
599 iport->selected_fcf.ka_disabled = 0; in fnic_common_fip_cleanup()
605 * fnic_fcoe_process_cvl - Processes Clear Virtual Link from FCF.
607 * @fiph: Received frame
614 struct fnic_iport_s *iport = &fnic->iport; in fnic_fcoe_process_cvl()
620 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_cvl()
623 if (!((cvl_msg->fcf_mac_desc.fd_desc.fip_dtype == 2) in fnic_fcoe_process_cvl()
624 && (cvl_msg->fcf_mac_desc.fd_desc.fip_dlen == 2)) in fnic_fcoe_process_cvl()
625 || !((cvl_msg->name_desc.fd_desc.fip_dtype == 4) in fnic_fcoe_process_cvl()
626 && (cvl_msg->name_desc.fd_desc.fip_dlen == 3))) { in fnic_fcoe_process_cvl()
628 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_cvl()
630 cvl_msg->fcf_mac_desc.fd_desc.fip_dtype, in fnic_fcoe_process_cvl()
631 cvl_msg->fcf_mac_desc.fd_desc.fip_dlen, in fnic_fcoe_process_cvl()
632 cvl_msg->name_desc.fd_desc.fip_dtype, in fnic_fcoe_process_cvl()
633 cvl_msg->name_desc.fd_desc.fip_dlen); in fnic_fcoe_process_cvl()
637 (iport->selected_fcf.fcf_mac, cvl_msg->fcf_mac_desc.fd_mac, ETH_ALEN) in fnic_fcoe_process_cvl()
639 for (i = 0; i < ((be16_to_cpu(fiph->fip_dl_len) / 5) - 1); i++) { in fnic_fcoe_process_cvl()
640 if (!((cvl_msg->vn_ports_desc[i].fd_desc.fip_dtype == 11) in fnic_fcoe_process_cvl()
641 && (cvl_msg->vn_ports_desc[i].fd_desc.fip_dlen == 5))) { in fnic_fcoe_process_cvl()
643 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_fcoe_process_cvl()
644 fnic->fnic_num, in fnic_fcoe_process_cvl()
646 cvl_msg->vn_ports_desc[i].fd_desc.fip_dtype, in fnic_fcoe_process_cvl()
647 cvl_msg->vn_ports_desc[i].fd_desc.fip_dlen); in fnic_fcoe_process_cvl()
650 (iport->fpma, cvl_msg->vn_ports_desc[i].fd_mac, in fnic_fcoe_process_cvl()
660 while (fnic->reset_in_progress == IN_PROGRESS) { in fnic_fcoe_process_cvl()
661 spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); in fnic_fcoe_process_cvl()
662 wait_for_completion_timeout(&fnic->reset_completion_wait, in fnic_fcoe_process_cvl()
664 spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags); in fnic_fcoe_process_cvl()
667 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_cvl()
672 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_fcoe_process_cvl()
676 fnic->reset_in_progress = IN_PROGRESS; in fnic_fcoe_process_cvl()
678 fnic->reset_in_progress = NOT_IN_PROGRESS; in fnic_fcoe_process_cvl()
679 complete(&fnic->reset_completion_wait); in fnic_fcoe_process_cvl()
685 * fdls_fip_recv_frame - Demultiplexer for FIP frames
687 * @frame: Received ethernet frame
689 int fdls_fip_recv_frame(struct fnic *fnic, void *frame) in fdls_fip_recv_frame() argument
691 struct ethhdr *eth = (struct ethhdr *)frame; in fdls_fip_recv_frame()
694 u8 sub; in fdls_fip_recv_frame() local
697 if (be16_to_cpu(eth->h_proto) == ETH_P_FIP) { in fdls_fip_recv_frame()
699 op = be16_to_cpu(fiph->fip_op); in fdls_fip_recv_frame()
700 sub = fiph->fip_subcode; in fdls_fip_recv_frame()
704 if (op == FIP_OP_DISC && sub == FIP_SC_REP) in fdls_fip_recv_frame()
706 else if (op == FIP_OP_VLAN && sub == FIP_SC_REP) in fdls_fip_recv_frame()
708 else if (op == FIP_OP_CTRL && sub == FIP_SC_REP) in fdls_fip_recv_frame()
710 else if (op == FIP_OP_LS && sub == FIP_SC_REP) in fdls_fip_recv_frame()
713 /* Return true if the frame was a FIP frame */ in fdls_fip_recv_frame()
717 FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fdls_fip_recv_frame()
718 "Not a FIP Frame"); in fdls_fip_recv_frame()
725 struct fnic_iport_s *iport = &fnic->iport; in fnic_work_on_fip_timer()
727 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_work_on_fip_timer()
730 if (iport->fip.state == FDLS_FIP_VLAN_DISCOVERY_STARTED) { in fnic_work_on_fip_timer()
732 } else if (iport->fip.state == FDLS_FIP_FCF_DISCOVERY_STARTED) { in fnic_work_on_fip_timer()
735 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_work_on_fip_timer()
737 if (memcmp(iport->selected_fcf.fcf_mac, zmac, ETH_ALEN) != 0) { in fnic_work_on_fip_timer()
739 if (iport->flags & FNIC_FIRST_LINK_UP) { in fnic_work_on_fip_timer()
740 fnic_scsi_fcpio_reset(iport->fnic); in fnic_work_on_fip_timer()
741 iport->flags &= ~FNIC_FIRST_LINK_UP; in fnic_work_on_fip_timer()
745 if (!((iport->selected_fcf.ka_disabled) in fnic_work_on_fip_timer()
746 || (iport->selected_fcf.fka_adv_period == 0))) { in fnic_work_on_fip_timer()
752 msecs_to_jiffies(iport->selected_fcf.fka_adv_period); in fnic_work_on_fip_timer()
753 mod_timer(&fnic->fcs_ka_timer, in fnic_work_on_fip_timer()
757 FNIC_FIP_DBG(KERN_INFO, fnic->host, in fnic_work_on_fip_timer()
758 fnic->fnic_num, "FCF Discovery timeout\n"); in fnic_work_on_fip_timer()
761 } else if (iport->fip.state == FDLS_FIP_FLOGI_STARTED) { in fnic_work_on_fip_timer()
762 fdls_schedule_oxid_free(iport, &iport->active_oxid_fabric_req); in fnic_work_on_fip_timer()
763 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_work_on_fip_timer()
765 if (iport->fip.flogi_retry < fnic->config.flogi_retries) in fnic_work_on_fip_timer()
773 * fnic_handle_fip_timer - Timeout handler for FIP discover phase.
782 INIT_WORK(&fnic->fip_timer_work, fnic_work_on_fip_timer); in fnic_handle_fip_timer()
783 queue_work(fnic_fip_queue, &fnic->fip_timer_work); in fnic_handle_fip_timer()
787 * fnic_handle_enode_ka_timer - FIP node keep alive.
792 uint8_t *frame; in fnic_handle_enode_ka_timer() local
795 struct fnic_iport_s *iport = &fnic->iport; in fnic_handle_enode_ka_timer()
800 if (iport->fip.state != FDLS_FIP_FLOGI_COMPLETE) in fnic_handle_enode_ka_timer()
803 if ((iport->selected_fcf.ka_disabled) in fnic_handle_enode_ka_timer()
804 || (iport->selected_fcf.fka_adv_period == 0)) { in fnic_handle_enode_ka_timer()
808 frame = fdls_alloc_frame(iport); in fnic_handle_enode_ka_timer()
809 if (frame == NULL) { in fnic_handle_enode_ka_timer()
810 FNIC_FIP_DBG(KERN_ERR, fnic->host, fnic->fnic_num, in fnic_handle_enode_ka_timer()
811 "Failed to allocate frame to send enode ka"); in fnic_handle_enode_ka_timer()
815 penode_ka = (struct fip_enode_ka *) frame; in fnic_handle_enode_ka_timer()
827 memcpy(penode_ka->eth.h_source, iport->hwmac, ETH_ALEN); in fnic_handle_enode_ka_timer()
828 memcpy(penode_ka->eth.h_dest, iport->selected_fcf.fcf_mac, ETH_ALEN); in fnic_handle_enode_ka_timer()
829 memcpy(penode_ka->mac_desc.fd_mac, iport->hwmac, ETH_ALEN); in fnic_handle_enode_ka_timer()
831 FNIC_FIP_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, in fnic_handle_enode_ka_timer()
833 fnic_send_fip_frame(iport, frame, frame_size); in fnic_handle_enode_ka_timer()
835 + msecs_to_jiffies(iport->selected_fcf.fka_adv_period); in fnic_handle_enode_ka_timer()
836 mod_timer(&fnic->enode_ka_timer, round_jiffies(enode_ka_tov)); in fnic_handle_enode_ka_timer()
840 * fnic_handle_vn_ka_timer - FIP virtual port keep alive.
845 uint8_t *frame; in fnic_handle_vn_ka_timer() local
848 struct fnic_iport_s *iport = &fnic->iport; in fnic_handle_vn_ka_timer()
854 if (iport->fip.state != FDLS_FIP_FLOGI_COMPLETE) in fnic_handle_vn_ka_timer()
857 if ((iport->selected_fcf.ka_disabled) in fnic_handle_vn_ka_timer()
858 || (iport->selected_fcf.fka_adv_period == 0)) { in fnic_handle_vn_ka_timer()
862 frame = fdls_alloc_frame(iport); in fnic_handle_vn_ka_timer()
863 if (frame == NULL) { in fnic_handle_vn_ka_timer()
864 FNIC_FIP_DBG(KERN_ERR, fnic->host, fnic->fnic_num, in fnic_handle_vn_ka_timer()
865 "Failed to allocate frame to send vn ka"); in fnic_handle_vn_ka_timer()
869 pvn_port_ka = (struct fip_vn_port_ka *) frame; in fnic_handle_vn_ka_timer()
882 memcpy(pvn_port_ka->eth.h_source, iport->fpma, ETH_ALEN); in fnic_handle_vn_ka_timer()
883 memcpy(pvn_port_ka->eth.h_dest, iport->selected_fcf.fcf_mac, ETH_ALEN); in fnic_handle_vn_ka_timer()
884 memcpy(pvn_port_ka->mac_desc.fd_mac, iport->hwmac, ETH_ALEN); in fnic_handle_vn_ka_timer()
885 memcpy(pvn_port_ka->vn_port_desc.fd_mac, iport->fpma, ETH_ALEN); in fnic_handle_vn_ka_timer()
886 hton24(fcid, iport->fcid); in fnic_handle_vn_ka_timer()
887 memcpy(pvn_port_ka->vn_port_desc.fd_fc_id, fcid, 3); in fnic_handle_vn_ka_timer()
888 FNIC_STD_SET_NPORT_NAME(&pvn_port_ka->vn_port_desc.fd_wwpn, iport->wwpn); in fnic_handle_vn_ka_timer()
890 FNIC_FIP_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, in fnic_handle_vn_ka_timer()
892 fnic_send_fip_frame(iport, frame, frame_size); in fnic_handle_vn_ka_timer()
894 mod_timer(&fnic->vn_ka_timer, round_jiffies(vn_ka_tov)); in fnic_handle_vn_ka_timer()
898 * fnic_vlan_discovery_timeout - Handle vlan discovery timeout
907 struct fnic_iport_s *iport = &fnic->iport; in fnic_vlan_discovery_timeout()
908 struct fnic_stats *fnic_stats = &fnic->fnic_stats; in fnic_vlan_discovery_timeout()
911 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_vlan_discovery_timeout()
912 if (fnic->stop_rx_link_events) { in fnic_vlan_discovery_timeout()
913 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_vlan_discovery_timeout()
916 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_vlan_discovery_timeout()
918 if (!iport->usefip) in fnic_vlan_discovery_timeout()
921 spin_lock_irqsave(&fnic->vlans_lock, flags); in fnic_vlan_discovery_timeout()
922 if (list_empty(&fnic->vlan_list)) { in fnic_vlan_discovery_timeout()
924 spin_unlock_irqrestore(&fnic->vlans_lock, flags); in fnic_vlan_discovery_timeout()
929 vlan = list_first_entry(&fnic->vlan_list, struct fcoe_vlan, list); in fnic_vlan_discovery_timeout()
931 if (vlan->state == FIP_VLAN_SENT) { in fnic_vlan_discovery_timeout()
932 if (vlan->sol_count >= FCOE_CTLR_MAX_SOL) { in fnic_vlan_discovery_timeout()
937 list_del(&vlan->list); in fnic_vlan_discovery_timeout()
940 if (list_empty(&fnic->vlan_list)) { in fnic_vlan_discovery_timeout()
942 spin_unlock_irqrestore(&fnic->vlans_lock, in fnic_vlan_discovery_timeout()
949 list_first_entry(&fnic->vlan_list, struct fcoe_vlan, in fnic_vlan_discovery_timeout()
952 fnic->set_vlan(fnic, vlan->vid); in fnic_vlan_discovery_timeout()
953 vlan->state = FIP_VLAN_SENT; /* sent now */ in fnic_vlan_discovery_timeout()
956 atomic64_inc(&fnic_stats->vlan_stats.sol_expiry_count); in fnic_vlan_discovery_timeout()
959 fnic->set_vlan(fnic, vlan->vid); in fnic_vlan_discovery_timeout()
960 vlan->state = FIP_VLAN_SENT; /* sent now */ in fnic_vlan_discovery_timeout()
962 vlan->sol_count++; in fnic_vlan_discovery_timeout()
963 spin_unlock_irqrestore(&fnic->vlans_lock, flags); in fnic_vlan_discovery_timeout()
968 * fnic_work_on_fcs_ka_timer - Handle work on FCS keep alive timer.
978 struct fnic_iport_s *iport = &fnic->iport; in fnic_work_on_fcs_ka_timer()
980 FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, in fnic_work_on_fcs_ka_timer()
984 spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags); in fnic_work_on_fcs_ka_timer()
986 iport->state = FNIC_IPORT_STATE_FIP; in fnic_work_on_fcs_ka_timer()
987 spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); in fnic_work_on_fcs_ka_timer()
993 * fnic_handle_fcs_ka_timer - Handle FCS keep alive timer.
1003 INIT_WORK(&fnic->fip_timer_work, fnic_work_on_fcs_ka_timer); in fnic_handle_fcs_ka_timer()
1004 queue_work(fnic_fip_queue, &fnic->fip_timer_work); in fnic_handle_fcs_ka_timer()