• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/scsi/fcoe/

Lines Matching defs:fip

87 #define LIBFCOE_FIP_DBG(fip, fmt, args...)				\
89 printk(KERN_INFO "host%d: fip: " fmt, \
90 (fip)->lp->host->host_no, ##args);)
118 * @fip: The FCoE controller
121 static void fcoe_ctlr_set_state(struct fcoe_ctlr *fip, enum fip_state state)
123 if (state == fip->state)
125 if (fip->lp)
126 LIBFCOE_FIP_DBG(fip, "state %s -> %s\n",
127 fcoe_ctlr_state(fip->state), fcoe_ctlr_state(state));
128 fip->state = state;
157 * @fip: The FCoE controller
159 static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
161 if (fip->mode == FIP_MODE_VN2VN)
162 hton24(fip->dest_addr, FIP_VN_FC_MAP);
164 hton24(fip->dest_addr, FIP_DEF_FC_MAP);
165 hton24(fip->dest_addr + 3, 0);
166 fip->map_dest = 1;
171 * @fip: The FCoE controller to initialize
173 void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
175 fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
176 fip->mode = mode;
177 INIT_LIST_HEAD(&fip->fcfs);
178 mutex_init(&fip->ctlr_mutex);
179 fip->flogi_oxid = FC_XID_UNKNOWN;
180 setup_timer(&fip->timer, fcoe_ctlr_timeout, (unsigned long)fip);
181 INIT_WORK(&fip->timer_work, fcoe_ctlr_timer_work);
182 INIT_WORK(&fip->recv_work, fcoe_ctlr_recv_work);
183 skb_queue_head_init(&fip->fip_recv_list);
189 * @fip: The FCoE controller whose FCFs are to be reset
193 static void fcoe_ctlr_reset_fcfs(struct fcoe_ctlr *fip)
198 fip->sel_fcf = NULL;
199 list_for_each_entry_safe(fcf, next, &fip->fcfs, list) {
203 fip->fcf_count = 0;
204 fip->sel_time = 0;
209 * @fip: The FCoE controller to tear down
219 void fcoe_ctlr_destroy(struct fcoe_ctlr *fip)
221 cancel_work_sync(&fip->recv_work);
222 skb_queue_purge(&fip->fip_recv_list);
224 mutex_lock(&fip->ctlr_mutex);
225 fcoe_ctlr_set_state(fip, FIP_ST_DISABLED);
226 fcoe_ctlr_reset_fcfs(fip);
227 mutex_unlock(&fip->ctlr_mutex);
228 del_timer_sync(&fip->timer);
229 cancel_work_sync(&fip->timer_work);
235 * @fip: The FCoE controller to get the maximum FCoE size from
240 static inline u32 fcoe_ctlr_fcoe_size(struct fcoe_ctlr *fip)
247 return fip->lp->mfs + sizeof(struct fc_frame_header) +
253 * @fip: The FCoE controller to send the solicitation on
256 static void fcoe_ctlr_solicit(struct fcoe_ctlr *fip, struct fcoe_fcf *fcf)
261 struct fip_header fip;
278 memcpy(sol->eth.h_source, fip->ctl_src_addr, ETH_ALEN);
281 sol->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
282 sol->fip.fip_op = htons(FIP_OP_DISC);
283 sol->fip.fip_subcode = FIP_SC_SOL;
284 sol->fip.fip_dl_len = htons(sizeof(sol->desc) / FIP_BPW);
285 sol->fip.fip_flags = htons(FIP_FL_FPMA);
286 if (fip->spma)
287 sol->fip.fip_flags |= htons(FIP_FL_SPMA);
291 memcpy(sol->desc.mac.fd_mac, fip->ctl_src_addr, ETH_ALEN);
295 put_unaligned_be64(fip->lp->wwnn, &sol->desc.wwnn.fd_wwn);
297 fcoe_size = fcoe_ctlr_fcoe_size(fip);
306 fip->send(fip, skb);
309 fip->sol_time = jiffies;
314 * @fip: The FCoE controller to start
318 void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
320 mutex_lock(&fip->ctlr_mutex);
321 if (fip->state == FIP_ST_NON_FIP || fip->state == FIP_ST_AUTO) {
322 mutex_unlock(&fip->ctlr_mutex);
323 fc_linkup(fip->lp);
324 } else if (fip->state == FIP_ST_LINK_WAIT) {
325 fcoe_ctlr_set_state(fip, fip->mode);
326 switch (fip->mode) {
328 LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);
331 LIBFCOE_FIP_DBG(fip, "%s", "setting AUTO mode.\n");
335 mutex_unlock(&fip->ctlr_mutex);
336 fc_linkup(fip->lp);
337 fcoe_ctlr_solicit(fip, NULL);
340 fcoe_ctlr_vn_start(fip);
341 mutex_unlock(&fip->ctlr_mutex);
342 fc_linkup(fip->lp);
346 mutex_unlock(&fip->ctlr_mutex);
352 * @fip: The FCoE controller to reset
354 static void fcoe_ctlr_reset(struct fcoe_ctlr *fip)
356 fcoe_ctlr_reset_fcfs(fip);
357 del_timer(&fip->timer);
358 fip->ctlr_ka_time = 0;
359 fip->port_ka_time = 0;
360 fip->sol_time = 0;
361 fip->flogi_oxid = FC_XID_UNKNOWN;
362 fcoe_ctlr_map_dest(fip);
367 * @fip: The FCoE controller to be stopped
374 int fcoe_ctlr_link_down(struct fcoe_ctlr *fip)
378 LIBFCOE_FIP_DBG(fip, "link down.\n");
379 mutex_lock(&fip->ctlr_mutex);
380 fcoe_ctlr_reset(fip);
381 link_dropped = fip->state != FIP_ST_LINK_WAIT;
382 fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
383 mutex_unlock(&fip->ctlr_mutex);
386 fc_linkdown(fip->lp);
393 * @fip: The FCoE controller to send the FKA on
405 static void fcoe_ctlr_send_keep_alive(struct fcoe_ctlr *fip,
412 struct fip_header fip;
420 fcf = fip->sel_fcf;
421 lp = fip->lp;
436 kal->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
437 kal->fip.fip_op = htons(FIP_OP_CTRL);
438 kal->fip.fip_subcode = FIP_SC_KEEP_ALIVE;
439 kal->fip.fip_dl_len = htons((sizeof(kal->mac) +
441 kal->fip.fip_flags = htons(FIP_FL_FPMA);
442 if (fip->spma)
443 kal->fip.fip_flags |= htons(FIP_FL_SPMA);
447 memcpy(kal->mac.fd_mac, fip->ctl_src_addr, ETH_ALEN);
452 memcpy(vn->fd_mac, fip->get_src_addr(lport), ETH_ALEN);
460 fip->send(fip, skb);
465 * @fip: The FCoE controller for the ELS frame
478 static int fcoe_ctlr_encaps(struct fcoe_ctlr *fip, struct fc_lport *lport,
483 struct fip_header fip;
500 if (fcoe_ctlr_vn_lookup(fip, d_id, cap->eth.h_dest))
504 fcf = fip->sel_fcf;
508 fip_flags &= fip->spma ? FIP_FL_SPMA | FIP_FL_FPMA :
514 memcpy(cap->eth.h_source, fip->ctl_src_addr, ETH_ALEN);
517 cap->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
518 cap->fip.fip_op = htons(FIP_OP_LS);
520 cap->fip.fip_subcode = FIP_SC_REP;
522 cap->fip.fip_subcode = FIP_SC_REQ;
523 cap->fip.fip_flags = htons(fip_flags);
535 memcpy(mac->fd_mac, fip->get_src_addr(lport), ETH_ALEN);
536 } else if (fip->mode == FIP_MODE_VN2VN) {
538 hton24(mac->fd_mac + 3, fip->port_id);
540 LIBFCOE_FIP_DBG(fip, "FLOGI/FDISC sent with SPMA\n");
541 memcpy(mac->fd_mac, fip->ctl_src_addr, ETH_ALEN);
543 LIBFCOE_FIP_DBG(fip, "FLOGI/FDISC sent with FPMA\n");
547 cap->fip.fip_dl_len = htons(dlen / FIP_BPW);
557 * @fip: FCoE controller.
568 int fcoe_ctlr_els_send(struct fcoe_ctlr *fip, struct fc_lport *lport,
581 if (op == ELS_FLOGI && fip->mode != FIP_MODE_VN2VN) {
582 old_xid = fip->flogi_oxid;
583 fip->flogi_oxid = ntohs(fh->fh_ox_id);
584 if (fip->state == FIP_ST_AUTO) {
586 fip->flogi_count = 0;
587 fip->flogi_count++;
588 if (fip->flogi_count < 3)
590 fcoe_ctlr_map_dest(fip);
593 if (fip->state == FIP_ST_NON_FIP)
594 fcoe_ctlr_map_dest(fip);
597 if (fip->state == FIP_ST_NON_FIP)
599 if (!fip->sel_fcf && fip->mode != FIP_MODE_VN2VN)
611 if (fip->mode == FIP_MODE_VN2VN) {
612 if (fip->state != FIP_ST_VNMP_UP)
617 if (fip->state != FIP_ST_ENABLED)
632 if (fip->state == FIP_ST_NON_FIP) {
633 if (fip->flogi_oxid == FC_XID_UNKNOWN)
635 fip->flogi_oxid = FC_XID_UNKNOWN;
637 fip->update_mac(lport, mac);
646 if (fip->state != FIP_ST_ENABLED &&
647 fip->state != FIP_ST_VNMP_UP)
651 LIBFCOE_FIP_DBG(fip, "els_send op %u d_id %x\n",
653 if (fcoe_ctlr_encaps(fip, lport, op, skb, ntoh24(fh->fh_d_id)))
655 fip->send(fip, skb);
665 * @fip: The FCoE controller to free FCFs on
680 static unsigned long fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip)
689 stats = per_cpu_ptr(fip->lp->dev_stats, get_cpu());
691 list_for_each_entry_safe(fcf, next, &fip->fcfs, list) {
693 if (fip->sel_fcf == fcf) {
699 fip->lp->host->host_no, fcf->fabric_name,
707 if (fip->sel_fcf == fcf)
708 fip->sel_fcf = NULL;
710 WARN_ON(!fip->fcf_count);
711 fip->fcf_count--;
723 if (sel_time && !fip->sel_fcf && !fip->sel_time) {
725 fip->sel_time = sel_time;
733 * @fip: The FCoE controller receiving the advertisement
740 static int fcoe_ctlr_parse_adv(struct fcoe_ctlr *fip,
777 LIBFCOE_FIP_DBG(fip, "Duplicate Critical "
795 LIBFCOE_FIP_DBG(fip,
836 LIBFCOE_FIP_DBG(fip, "unexpected descriptor type %x "
851 LIBFCOE_FIP_DBG(fip, "adv missing descriptors mask %x\n",
858 LIBFCOE_FIP_DBG(fip, "FIP length error in descriptor type %x len %zu\n",
865 * @fip: The FCoE controller receiving the advertisement
868 static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, struct sk_buff *skb)
877 if (fcoe_ctlr_parse_adv(fip, skb, &new))
880 mutex_lock(&fip->ctlr_mutex);
881 first = list_empty(&fip->fcfs);
883 list_for_each_entry(fcf, &fip->fcfs, list) {
893 if (fip->fcf_count >= FCOE_CTLR_FCF_LIMIT)
900 fip->fcf_count++;
902 list_add(&fcf->list, &fip->fcfs);
914 if (fcf == fip->sel_fcf && !fcf->fd_flags) {
915 fip->ctlr_ka_time -= fcf->fka_period;
916 fip->ctlr_ka_time += new.fka_period;
917 if (time_before(fip->ctlr_ka_time, fip->timer.expires))
918 mod_timer(&fip->timer, fip->ctlr_ka_time);
926 LIBFCOE_FIP_DBG(fip, "New FCF for fab %16.16llx "
936 fcoe_ctlr_solicit(fip, fcf);
944 if (first && time_after(jiffies, fip->sol_time + sol_tov))
945 fcoe_ctlr_solicit(fip, NULL);
951 if (mtu_valid && !fip->sel_fcf && fcoe_ctlr_fcf_usable(fcf)) {
952 fip->sel_time = jiffies +
954 if (!timer_pending(&fip->timer) ||
955 time_before(fip->sel_time, fip->timer.expires))
956 mod_timer(&fip->timer, fip->sel_time);
959 mutex_unlock(&fip->ctlr_mutex);
964 * @fip: The FCoE controller which received the packet
967 static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb)
969 struct fc_lport *lport = fip->lp;
1004 LIBFCOE_FIP_DBG(fip, "Duplicate Critical "
1013 LIBFCOE_FIP_DBG(fip, "FIP descriptors "
1029 LIBFCOE_FIP_DBG(fip, "FIP descriptors "
1043 LIBFCOE_FIP_DBG(fip, "unexpected descriptor type %x "
1049 LIBFCOE_FIP_DBG(fip, "FIP descriptors "
1065 fip->mode != FIP_MODE_VN2VN) {
1067 LIBFCOE_FIP_DBG(fip,
1074 if (fip->flogi_oxid == ntohs(fh->fh_ox_id))
1075 fip->flogi_oxid = FC_XID_UNKNOWN;
1080 LIBFCOE_FIP_DBG(fip, "Missing critical descriptors "
1106 LIBFCOE_FIP_DBG(fip, "FIP length error in descriptor type %x len %zu\n",
1114 * @fip: The FCoE controller that received the frame
1120 static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
1129 struct fcoe_fcf *fcf = fip->sel_fcf;
1130 struct fc_lport *lport = fip->lp;
1135 LIBFCOE_FIP_DBG(fip, "Clear Virtual Link received\n");
1154 LIBFCOE_FIP_DBG(fip, "Duplicate Critical "
1180 fip->get_src_addr(lport)) == 0 &&
1190 fip->get_src_addr(vn_port)) == 0 &&
1217 LIBFCOE_FIP_DBG(fip, "missing descriptors mask %x\n",
1220 LIBFCOE_FIP_DBG(fip, "performing Clear Virtual Link\n");
1225 mutex_lock(&fip->ctlr_mutex);
1229 fcoe_ctlr_reset(fip);
1230 mutex_unlock(&fip->ctlr_mutex);
1232 fc_lport_reset(fip->lp);
1233 fcoe_ctlr_solicit(fip, NULL);
1240 * @fip: The FCoE controller that received the packet
1245 void fcoe_ctlr_recv(struct fcoe_ctlr *fip, struct sk_buff *skb)
1247 skb_queue_tail(&fip->fip_recv_list, skb);
1248 schedule_work(&fip->recv_work);
1254 * @fip: The FCoE controller that received the frame
1259 static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, struct sk_buff *skb)
1272 if (fip->mode == FIP_MODE_VN2VN) {
1273 if (compare_ether_addr(eh->h_dest, fip->ctl_src_addr) &&
1277 } else if (compare_ether_addr(eh->h_dest, fip->ctl_src_addr) &&
1289 mutex_lock(&fip->ctlr_mutex);
1290 state = fip->state;
1292 fip->map_dest = 0;
1293 fcoe_ctlr_set_state(fip, FIP_ST_ENABLED);
1295 LIBFCOE_FIP_DBG(fip, "Using FIP mode\n");
1297 mutex_unlock(&fip->ctlr_mutex);
1299 if (fip->mode == FIP_MODE_VN2VN && op == FIP_OP_VN2VN)
1300 return fcoe_ctlr_vn_recv(fip, skb);
1307 fcoe_ctlr_recv_els(fip, skb); /* consumes skb */
1315 fcoe_ctlr_recv_adv(fip, skb);
1317 fcoe_ctlr_recv_clr_vlink(fip, fiph);
1327 * @fip: The FCoE controller
1333 static void fcoe_ctlr_select(struct fcoe_ctlr *fip)
1338 list_for_each_entry(fcf, &fip->fcfs, list) {
1339 LIBFCOE_FIP_DBG(fip, "consider FCF for fab %16.16llx "
1344 LIBFCOE_FIP_DBG(fip, "FCF for fab %16.16llx "
1359 LIBFCOE_FIP_DBG(fip, "Conflicting fabric, VFID, "
1366 fip->sel_fcf = best;
1375 struct fcoe_ctlr *fip = (struct fcoe_ctlr *)arg;
1377 schedule_work(&fip->timer_work);
1389 struct fcoe_ctlr *fip;
1399 fip = container_of(work, struct fcoe_ctlr, timer_work);
1400 if (fip->mode == FIP_MODE_VN2VN)
1401 return fcoe_ctlr_vn_timeout(fip);
1402 mutex_lock(&fip->ctlr_mutex);
1403 if (fip->state == FIP_ST_DISABLED) {
1404 mutex_unlock(&fip->ctlr_mutex);
1408 fcf = fip->sel_fcf;
1409 next_timer = fcoe_ctlr_age_fcfs(fip);
1411 sel = fip->sel_fcf;
1412 if (!sel && fip->sel_time) {
1413 if (time_after_eq(jiffies, fip->sel_time)) {
1414 fcoe_ctlr_select(fip);
1415 sel = fip->sel_fcf;
1416 fip->sel_time = 0;
1417 } else if (time_after(next_timer, fip->sel_time))
1418 next_timer = fip->sel_time;
1426 fip->lp->host->host_no, sel->fcf_mac);
1427 memcpy(fip->dest_addr, sel->fcf_mac, ETH_ALEN);
1428 fip->map_dest = 0;
1429 fip->port_ka_time = jiffies +
1431 fip->ctlr_ka_time = jiffies + sel->fka_period;
1432 if (time_after(next_timer, fip->ctlr_ka_time))
1433 next_timer = fip->ctlr_ka_time;
1438 fip->lp->host->host_no);
1444 if (time_after_eq(jiffies, fip->ctlr_ka_time)) {
1445 fip->ctlr_ka_time = jiffies + sel->fka_period;
1448 if (time_after(next_timer, fip->ctlr_ka_time))
1449 next_timer = fip->ctlr_ka_time;
1451 if (time_after_eq(jiffies, fip->port_ka_time)) {
1452 fip->port_ka_time = jiffies +
1456 if (time_after(next_timer, fip->port_ka_time))
1457 next_timer = fip->port_ka_time;
1459 if (!list_empty(&fip->fcfs))
1460 mod_timer(&fip->timer, next_timer);
1461 mutex_unlock(&fip->ctlr_mutex);
1464 fc_lport_reset(fip->lp);
1466 fcoe_ctlr_solicit(fip, NULL);
1470 fcoe_ctlr_send_keep_alive(fip, NULL, 0, fip->ctl_src_addr);
1473 mutex_lock(&fip->lp->lp_mutex);
1474 mac = fip->get_src_addr(fip->lp);
1475 fcoe_ctlr_send_keep_alive(fip, fip->lp, 1, mac);
1476 list_for_each_entry(vport, &fip->lp->vports, list) {
1477 mac = fip->get_src_addr(vport);
1478 fcoe_ctlr_send_keep_alive(fip, vport, 1, mac);
1480 mutex_unlock(&fip->lp->lp_mutex);
1490 struct fcoe_ctlr *fip;
1493 fip = container_of(recv_work, struct fcoe_ctlr, recv_work);
1494 while ((skb = skb_dequeue(&fip->fip_recv_list)))
1495 fcoe_ctlr_recv_handler(fip, skb);
1500 * @fip: The FCoE controller
1506 * by fip->flogi_oxid != FC_XID_UNKNOWN.
1513 int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_lport *lport,
1527 fip->flogi_oxid == ntohs(fh->fh_ox_id)) {
1529 mutex_lock(&fip->ctlr_mutex);
1530 if (fip->state != FIP_ST_AUTO && fip->state != FIP_ST_NON_FIP) {
1531 mutex_unlock(&fip->ctlr_mutex);
1534 fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
1535 LIBFCOE_FIP_DBG(fip,
1545 fcoe_ctlr_map_dest(fip);
1547 memcpy(fip->dest_addr, sa, ETH_ALEN);
1548 fip->map_dest = 0;
1550 fip->flogi_oxid = FC_XID_UNKNOWN;
1551 mutex_unlock(&fip->ctlr_mutex);
1557 mutex_lock(&fip->ctlr_mutex);
1558 if (fip->state == FIP_ST_AUTO || fip->state == FIP_ST_NON_FIP) {
1559 memcpy(fip->dest_addr, sa, ETH_ALEN);
1560 fip->map_dest = 0;
1561 if (fip->state == FIP_ST_AUTO)
1562 LIBFCOE_FIP_DBG(fip, "received non-FIP FLOGI. "
1564 fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
1566 mutex_unlock(&fip->ctlr_mutex);
1624 * @fip: The FCoE controller
1629 static void fcoe_ctlr_vn_send(struct fcoe_ctlr *fip,
1636 struct fip_header fip;
1664 memcpy(frame->eth.h_source, fip->ctl_src_addr, ETH_ALEN);
1667 frame->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
1668 frame->fip.fip_op = htons(FIP_OP_VN2VN);
1669 frame->fip.fip_subcode = sub;
1670 frame->fip.fip_dl_len = htons(dlen / FIP_BPW);
1674 memcpy(frame->mac.fd_mac, fip->ctl_src_addr, ETH_ALEN);
1678 put_unaligned_be64(fip->lp->wwnn, &frame->wwnn.fd_wwn);
1683 hton24(frame->vn.fd_mac + 3, fip->port_id);
1684 hton24(frame->vn.fd_fc_id, fip->port_id);
1685 put_unaligned_be64(fip->lp->wwpn, &frame->vn.fd_wwpn);
1695 ff->fd_fts = fip->lp->fcts;
1698 if (fip->lp->service_params & FCP_SPPF_INIT_FCN)
1700 if (fip->lp->service_params & FCP_SPPF_TARG_FCN)
1708 size->fd_size = htons(fcoe_ctlr_fcoe_size(fip));
1716 fip->send(fip, skb);
1731 struct fcoe_ctlr *fip = lport->disc.priv;
1734 LIBFCOE_FIP_DBG(fip, "vn_rport_callback %x event %d\n",
1737 mutex_lock(&fip->ctlr_mutex);
1747 LIBFCOE_FIP_DBG(fip,
1756 mutex_unlock(&fip->ctlr_mutex);
1765 * @fip: The FCoE controller
1778 * @fip: The FCoE controller
1785 struct fcoe_ctlr *fip = lport->disc.priv;
1787 mutex_lock(&fip->ctlr_mutex);
1789 mutex_unlock(&fip->ctlr_mutex);
1794 * @fip: The FCoE controller
1808 * @fip: The FCoE controller
1812 static void fcoe_ctlr_vn_restart(struct fcoe_ctlr *fip)
1817 fcoe_ctlr_disc_stop_locked(fip->lp);
1826 port_id = fip->port_id;
1827 if (fip->probe_tries)
1828 port_id = prandom32(&fip->rnd_state) & 0xffff;
1830 port_id = fip->lp->wwpn & 0xffff;
1833 fip->port_id = port_id;
1835 if (fip->probe_tries < FIP_VN_RLIM_COUNT) {
1836 fip->probe_tries++;
1840 mod_timer(&fip->timer, jiffies + msecs_to_jiffies(wait));
1841 fcoe_ctlr_set_state(fip, FIP_ST_VNMP_START);
1846 * @fip: The FCoE controller
1850 static void fcoe_ctlr_vn_start(struct fcoe_ctlr *fip)
1852 fip->probe_tries = 0;
1853 prandom32_seed(&fip->rnd_state, fip->lp->wwpn);
1854 fcoe_ctlr_vn_restart(fip);
1859 * @fip: The FCoE controller
1866 static int fcoe_ctlr_vn_parse(struct fcoe_ctlr *fip,
1904 LIBFCOE_FIP_DBG(fip, "vn_parse unknown subcode %u\n", sub);
1921 LIBFCOE_FIP_DBG(fip,
1937 LIBFCOE_FIP_DBG(fip,
1969 LIBFCOE_FIP_DBG(fip, "unexpected descriptor type %x "
1982 LIBFCOE_FIP_DBG(fip, "FIP length error in descriptor type %x len %zu\n",
1989 * @fip: The FCoE controller
1993 static void fcoe_ctlr_vn_send_claim(struct fcoe_ctlr *fip)
1995 fcoe_ctlr_vn_send(fip, FIP_SC_VN_CLAIM_NOTIFY, fcoe_all_vn2vn, 0);
1996 fip->sol_time = jiffies;
2001 * @fip: The FCoE controller
2006 static void fcoe_ctlr_vn_probe_req(struct fcoe_ctlr *fip,
2011 if (rdata->ids.port_id != fip->port_id)
2014 switch (fip->state) {
2017 fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REP,
2029 if (fip->lp->wwpn > rdata->ids.port_name &&
2031 fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REP,
2037 fcoe_ctlr_vn_restart(fip);
2046 * @fip: The FCoE controller
2051 static void fcoe_ctlr_vn_probe_reply(struct fcoe_ctlr *fip,
2054 if (rdata->ids.port_id != fip->port_id)
2056 switch (fip->state) {
2061 fcoe_ctlr_vn_restart(fip);
2064 fcoe_ctlr_vn_send_claim(fip);
2073 * @fip: The FCoE controller
2078 static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, struct fc_rport_priv *new)
2080 struct fc_lport *lport = fip->lp;
2087 if (port_id == fip->port_id)
2109 LIBFCOE_FIP_DBG(fip, "vn_add rport %6.6x %s\n",
2117 * @fip: The FCoE controller
2123 static int fcoe_ctlr_vn_lookup(struct fcoe_ctlr *fip, u32 port_id, u8 *mac)
2125 struct fc_lport *lport = fip->lp;
2143 * @fip: The FCoE controller
2148 static void fcoe_ctlr_vn_claim_notify(struct fcoe_ctlr *fip,
2154 fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REQ, fcoe_all_vn2vn, 0);
2157 switch (fip->state) {
2161 if (new->ids.port_id == fip->port_id)
2162 fcoe_ctlr_vn_restart(fip);
2166 if (new->ids.port_id == fip->port_id) {
2167 if (new->ids.port_name > fip->lp->wwpn) {
2168 fcoe_ctlr_vn_restart(fip);
2171 fcoe_ctlr_vn_send_claim(fip);
2174 fcoe_ctlr_vn_send(fip, FIP_SC_VN_CLAIM_REP, frport->enode_mac,
2176 fcoe_ctlr_fcoe_size(fip)));
2177 fcoe_ctlr_vn_add(fip, new);
2186 * @fip: The FCoE controller that received the frame
2191 static void fcoe_ctlr_vn_claim_resp(struct fcoe_ctlr *fip,
2194 LIBFCOE_FIP_DBG(fip, "claim resp from from rport %x - state %s\n",
2195 new->ids.port_id, fcoe_ctlr_state(fip->state));
2196 if (fip->state == FIP_ST_VNMP_UP || fip->state == FIP_ST_VNMP_CLAIM)
2197 fcoe_ctlr_vn_add(fip, new);
2202 * @fip: The FCoE controller that received the frame
2207 static void fcoe_ctlr_vn_beacon(struct fcoe_ctlr *fip,
2210 struct fc_lport *lport = fip->lp;
2216 fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REQ, fcoe_all_vn2vn, 0);
2228 if (!frport->time && fip->state == FIP_ST_VNMP_UP)
2235 if (fip->state != FIP_ST_VNMP_UP)
2243 LIBFCOE_FIP_DBG(fip, "beacon from new rport %x. sending claim notify\n",
2246 fip->sol_time + msecs_to_jiffies(FIP_VN_ANN_WAIT)))
2247 fcoe_ctlr_vn_send_claim(fip);
2252 * @fip: The FCoE controller
2258 static unsigned long fcoe_ctlr_vn_age(struct fcoe_ctlr *fip)
2260 struct fc_lport *lport = fip->lp;
2276 LIBFCOE_FIP_DBG(fip,
2289 * @fip: The FCoE controller that received the frame
2295 static int fcoe_ctlr_vn_recv(struct fcoe_ctlr *fip, struct sk_buff *skb)
2308 rc = fcoe_ctlr_vn_parse(fip, skb, &buf.rdata);
2310 LIBFCOE_FIP_DBG(fip, "vn_recv vn_parse error %d\n", rc);
2314 mutex_lock(&fip->ctlr_mutex);
2317 fcoe_ctlr_vn_probe_req(fip, &buf.rdata);
2320 fcoe_ctlr_vn_probe_reply(fip, &buf.rdata);
2323 fcoe_ctlr_vn_claim_notify(fip, &buf.rdata);
2326 fcoe_ctlr_vn_claim_resp(fip, &buf.rdata);
2329 fcoe_ctlr_vn_beacon(fip, &buf.rdata);
2332 LIBFCOE_FIP_DBG(fip, "vn_recv unknown subcode %d\n", sub);
2336 mutex_unlock(&fip->ctlr_mutex);
2362 * @fip: The FCoE controller
2377 struct fcoe_ctlr *fip = disc->priv;
2383 schedule_work(&fip->timer_work);
2389 * @fip: The FCoE controller
2395 static void fcoe_ctlr_vn_disc(struct fcoe_ctlr *fip)
2397 struct fc_lport *lport = fip->lp;
2418 * @fip: The FCoE controller
2420 static void fcoe_ctlr_vn_timeout(struct fcoe_ctlr *fip)
2426 mutex_lock(&fip->ctlr_mutex);
2427 switch (fip->state) {
2429 fcoe_ctlr_set_state(fip, FIP_ST_VNMP_PROBE1);
2430 fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REQ, fcoe_all_vn2vn, 0);
2434 fcoe_ctlr_set_state(fip, FIP_ST_VNMP_PROBE2);
2435 fcoe_ctlr_vn_send(fip, FIP_SC_VN_PROBE_REQ, fcoe_all_vn2vn, 0);
2439 fcoe_ctlr_set_state(fip, FIP_ST_VNMP_CLAIM);
2440 new_port_id = fip->port_id;
2443 fcoe_ctlr_map_dest(fip);
2444 fip->update_mac(fip->lp, mac);
2445 fcoe_ctlr_vn_send_claim(fip);
2453 next_time = fip->sol_time + msecs_to_jiffies(FIP_VN_ANN_WAIT);
2455 fcoe_ctlr_set_state(fip, FIP_ST_VNMP_UP);
2456 fcoe_ctlr_vn_send(fip, FIP_SC_VN_BEACON,
2459 fip->port_ka_time = next_time;
2461 fcoe_ctlr_vn_disc(fip);
2464 next_time = fcoe_ctlr_vn_age(fip);
2465 if (time_after_eq(jiffies, fip->port_ka_time)) {
2466 fcoe_ctlr_vn_send(fip, FIP_SC_VN_BEACON,
2468 fip->port_ka_time = jiffies +
2472 if (time_before(fip->port_ka_time, next_time))
2473 next_time = fip->port_ka_time;
2478 WARN(1, "unexpected state %d", fip->state);
2481 mod_timer(&fip->timer, next_time);
2483 mutex_unlock(&fip->ctlr_mutex);
2487 fc_lport_set_local_id(fip->lp, new_port_id);
2493 * @fip: The FCoE controller in use by the local port
2499 int fcoe_libfc_config(struct fc_lport *lport, struct fcoe_ctlr *fip,
2509 if (fip->mode == FIP_MODE_VN2VN)
2512 if (fip->mode == FIP_MODE_VN2VN) {
2520 lport->disc.priv = fip;