aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/fcoe/libfcoe.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/fcoe/libfcoe.c')
-rw-r--r--drivers/scsi/fcoe/libfcoe.c318
1 files changed, 136 insertions, 182 deletions
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c
index e419f486cdb3..5548bf3bb58b 100644
--- a/drivers/scsi/fcoe/libfcoe.c
+++ b/drivers/scsi/fcoe/libfcoe.c
@@ -49,6 +49,7 @@
49static int debug_fcoe; 49static int debug_fcoe;
50 50
51#define FCOE_MAX_QUEUE_DEPTH 256 51#define FCOE_MAX_QUEUE_DEPTH 256
52#define FCOE_LOW_QUEUE_DEPTH 32
52 53
53/* destination address mode */ 54/* destination address mode */
54#define FCOE_GW_ADDR_MODE 0x00 55#define FCOE_GW_ADDR_MODE 0x00
@@ -69,8 +70,6 @@ struct fcoe_percpu_s *fcoe_percpu[NR_CPUS];
69 70
70/* Function Prototyes */ 71/* Function Prototyes */
71static int fcoe_check_wait_queue(struct fc_lport *); 72static int fcoe_check_wait_queue(struct fc_lport *);
72static void fcoe_insert_wait_queue_head(struct fc_lport *, struct sk_buff *);
73static void fcoe_insert_wait_queue(struct fc_lport *, struct sk_buff *);
74static void fcoe_recv_flogi(struct fcoe_softc *, struct fc_frame *, u8 *); 73static void fcoe_recv_flogi(struct fcoe_softc *, struct fc_frame *, u8 *);
75#ifdef CONFIG_HOTPLUG_CPU 74#ifdef CONFIG_HOTPLUG_CPU
76static int fcoe_cpu_callback(struct notifier_block *, ulong, void *); 75static int fcoe_cpu_callback(struct notifier_block *, ulong, void *);
@@ -91,13 +90,13 @@ static struct notifier_block fcoe_cpu_notifier = {
91}; 90};
92 91
93/** 92/**
94 * fcoe_create_percpu_data - creates the associated cpu data 93 * fcoe_create_percpu_data() - creates the associated cpu data
95 * @cpu: index for the cpu where fcoe cpu data will be created 94 * @cpu: index for the cpu where fcoe cpu data will be created
96 * 95 *
97 * create percpu stats block, from cpu add notifier 96 * create percpu stats block, from cpu add notifier
98 * 97 *
99 * Returns: none 98 * Returns: none
100 **/ 99 */
101static void fcoe_create_percpu_data(int cpu) 100static void fcoe_create_percpu_data(int cpu)
102{ 101{
103 struct fc_lport *lp; 102 struct fc_lport *lp;
@@ -115,13 +114,13 @@ static void fcoe_create_percpu_data(int cpu)
115} 114}
116 115
117/** 116/**
118 * fcoe_destroy_percpu_data - destroys the associated cpu data 117 * fcoe_destroy_percpu_data() - destroys the associated cpu data
119 * @cpu: index for the cpu where fcoe cpu data will destroyed 118 * @cpu: index for the cpu where fcoe cpu data will destroyed
120 * 119 *
121 * destroy percpu stats block called by cpu add/remove notifier 120 * destroy percpu stats block called by cpu add/remove notifier
122 * 121 *
123 * Retuns: none 122 * Retuns: none
124 **/ 123 */
125static void fcoe_destroy_percpu_data(int cpu) 124static void fcoe_destroy_percpu_data(int cpu)
126{ 125{
127 struct fc_lport *lp; 126 struct fc_lport *lp;
@@ -137,7 +136,7 @@ static void fcoe_destroy_percpu_data(int cpu)
137} 136}
138 137
139/** 138/**
140 * fcoe_cpu_callback - fcoe cpu hotplug event callback 139 * fcoe_cpu_callback() - fcoe cpu hotplug event callback
141 * @nfb: callback data block 140 * @nfb: callback data block
142 * @action: event triggering the callback 141 * @action: event triggering the callback
143 * @hcpu: index for the cpu of this event 142 * @hcpu: index for the cpu of this event
@@ -145,7 +144,7 @@ static void fcoe_destroy_percpu_data(int cpu)
145 * this creates or destroys per cpu data for fcoe 144 * this creates or destroys per cpu data for fcoe
146 * 145 *
147 * Returns NOTIFY_OK always. 146 * Returns NOTIFY_OK always.
148 **/ 147 */
149static int fcoe_cpu_callback(struct notifier_block *nfb, unsigned long action, 148static int fcoe_cpu_callback(struct notifier_block *nfb, unsigned long action,
150 void *hcpu) 149 void *hcpu)
151{ 150{
@@ -166,7 +165,7 @@ static int fcoe_cpu_callback(struct notifier_block *nfb, unsigned long action,
166#endif /* CONFIG_HOTPLUG_CPU */ 165#endif /* CONFIG_HOTPLUG_CPU */
167 166
168/** 167/**
169 * fcoe_rcv - this is the fcoe receive function called by NET_RX_SOFTIRQ 168 * fcoe_rcv() - this is the fcoe receive function called by NET_RX_SOFTIRQ
170 * @skb: the receive skb 169 * @skb: the receive skb
171 * @dev: associated net device 170 * @dev: associated net device
172 * @ptype: context 171 * @ptype: context
@@ -175,7 +174,7 @@ static int fcoe_cpu_callback(struct notifier_block *nfb, unsigned long action,
175 * this function will receive the packet and build fc frame and pass it up 174 * this function will receive the packet and build fc frame and pass it up
176 * 175 *
177 * Returns: 0 for success 176 * Returns: 0 for success
178 **/ 177 */
179int fcoe_rcv(struct sk_buff *skb, struct net_device *dev, 178int fcoe_rcv(struct sk_buff *skb, struct net_device *dev,
180 struct packet_type *ptype, struct net_device *olddev) 179 struct packet_type *ptype, struct net_device *olddev)
181{ 180{
@@ -265,11 +264,11 @@ err2:
265EXPORT_SYMBOL_GPL(fcoe_rcv); 264EXPORT_SYMBOL_GPL(fcoe_rcv);
266 265
267/** 266/**
268 * fcoe_start_io - pass to netdev to start xmit for fcoe 267 * fcoe_start_io() - pass to netdev to start xmit for fcoe
269 * @skb: the skb to be xmitted 268 * @skb: the skb to be xmitted
270 * 269 *
271 * Returns: 0 for success 270 * Returns: 0 for success
272 **/ 271 */
273static inline int fcoe_start_io(struct sk_buff *skb) 272static inline int fcoe_start_io(struct sk_buff *skb)
274{ 273{
275 int rc; 274 int rc;
@@ -283,12 +282,12 @@ static inline int fcoe_start_io(struct sk_buff *skb)
283} 282}
284 283
285/** 284/**
286 * fcoe_get_paged_crc_eof - in case we need alloc a page for crc_eof 285 * fcoe_get_paged_crc_eof() - in case we need alloc a page for crc_eof
287 * @skb: the skb to be xmitted 286 * @skb: the skb to be xmitted
288 * @tlen: total len 287 * @tlen: total len
289 * 288 *
290 * Returns: 0 for success 289 * Returns: 0 for success
291 **/ 290 */
292static int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen) 291static int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen)
293{ 292{
294 struct fcoe_percpu_s *fps; 293 struct fcoe_percpu_s *fps;
@@ -326,13 +325,12 @@ static int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen)
326} 325}
327 326
328/** 327/**
329 * fcoe_fc_crc - calculates FC CRC in this fcoe skb 328 * fcoe_fc_crc() - calculates FC CRC in this fcoe skb
330 * @fp: the fc_frame containg data to be checksummed 329 * @fp: the fc_frame containg data to be checksummed
331 * 330 *
332 * This uses crc32() to calculate the crc for fc frame 331 * This uses crc32() to calculate the crc for fc frame
333 * Return : 32 bit crc 332 * Return : 32 bit crc
334 * 333 */
335 **/
336u32 fcoe_fc_crc(struct fc_frame *fp) 334u32 fcoe_fc_crc(struct fc_frame *fp)
337{ 335{
338 struct sk_buff *skb = fp_skb(fp); 336 struct sk_buff *skb = fp_skb(fp);
@@ -363,13 +361,12 @@ u32 fcoe_fc_crc(struct fc_frame *fp)
363EXPORT_SYMBOL_GPL(fcoe_fc_crc); 361EXPORT_SYMBOL_GPL(fcoe_fc_crc);
364 362
365/** 363/**
366 * fcoe_xmit - FCoE frame transmit function 364 * fcoe_xmit() - FCoE frame transmit function
367 * @lp: the associated local port 365 * @lp: the associated local port
368 * @fp: the fc_frame to be transmitted 366 * @fp: the fc_frame to be transmitted
369 * 367 *
370 * Return : 0 for success 368 * Return : 0 for success
371 * 369 */
372 **/
373int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) 370int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
374{ 371{
375 int wlen, rc = 0; 372 int wlen, rc = 0;
@@ -389,7 +386,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
389 386
390 WARN_ON((fr_len(fp) % sizeof(u32)) != 0); 387 WARN_ON((fr_len(fp) % sizeof(u32)) != 0);
391 388
392 fc = fcoe_softc(lp); 389 fc = lport_priv(lp);
393 /* 390 /*
394 * if it is a flogi then we need to learn gw-addr 391 * if it is a flogi then we need to learn gw-addr
395 * and my own fcid 392 * and my own fcid
@@ -439,7 +436,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
439 if (skb_is_nonlinear(skb)) { 436 if (skb_is_nonlinear(skb)) {
440 skb_frag_t *frag; 437 skb_frag_t *frag;
441 if (fcoe_get_paged_crc_eof(skb, tlen)) { 438 if (fcoe_get_paged_crc_eof(skb, tlen)) {
442 kfree(skb); 439 kfree_skb(skb);
443 return -ENOMEM; 440 return -ENOMEM;
444 } 441 }
445 frag = &skb_shinfo(skb)->frags[skb_shinfo(skb)->nr_frags - 1]; 442 frag = &skb_shinfo(skb)->frags[skb_shinfo(skb)->nr_frags - 1];
@@ -502,21 +499,22 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
502 rc = fcoe_start_io(skb); 499 rc = fcoe_start_io(skb);
503 500
504 if (rc) { 501 if (rc) {
505 fcoe_insert_wait_queue(lp, skb); 502 spin_lock_bh(&fc->fcoe_pending_queue.lock);
503 __skb_queue_tail(&fc->fcoe_pending_queue, skb);
504 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
506 if (fc->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH) 505 if (fc->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH)
507 fc_pause(lp); 506 lp->qfull = 1;
508 } 507 }
509 508
510 return 0; 509 return 0;
511} 510}
512EXPORT_SYMBOL_GPL(fcoe_xmit); 511EXPORT_SYMBOL_GPL(fcoe_xmit);
513 512
514/* 513/**
515 * fcoe_percpu_receive_thread - recv thread per cpu 514 * fcoe_percpu_receive_thread() - recv thread per cpu
516 * @arg: ptr to the fcoe per cpu struct 515 * @arg: ptr to the fcoe per cpu struct
517 * 516 *
518 * Return: 0 for success 517 * Return: 0 for success
519 *
520 */ 518 */
521int fcoe_percpu_receive_thread(void *arg) 519int fcoe_percpu_receive_thread(void *arg)
522{ 520{
@@ -533,7 +531,7 @@ int fcoe_percpu_receive_thread(void *arg)
533 struct fcoe_softc *fc; 531 struct fcoe_softc *fc;
534 struct fcoe_hdr *hp; 532 struct fcoe_hdr *hp;
535 533
536 set_user_nice(current, 19); 534 set_user_nice(current, -20);
537 535
538 while (!kthread_should_stop()) { 536 while (!kthread_should_stop()) {
539 537
@@ -658,7 +656,7 @@ int fcoe_percpu_receive_thread(void *arg)
658} 656}
659 657
660/** 658/**
661 * fcoe_recv_flogi - flogi receive function 659 * fcoe_recv_flogi() - flogi receive function
662 * @fc: associated fcoe_softc 660 * @fc: associated fcoe_softc
663 * @fp: the recieved frame 661 * @fp: the recieved frame
664 * @sa: the source address of this flogi 662 * @sa: the source address of this flogi
@@ -667,7 +665,7 @@ int fcoe_percpu_receive_thread(void *arg)
667 * mac address for the initiator, eitehr OUI based or GW based. 665 * mac address for the initiator, eitehr OUI based or GW based.
668 * 666 *
669 * Returns: none 667 * Returns: none
670 **/ 668 */
671static void fcoe_recv_flogi(struct fcoe_softc *fc, struct fc_frame *fp, u8 *sa) 669static void fcoe_recv_flogi(struct fcoe_softc *fc, struct fc_frame *fp, u8 *sa)
672{ 670{
673 struct fc_frame_header *fh; 671 struct fc_frame_header *fh;
@@ -715,32 +713,23 @@ static void fcoe_recv_flogi(struct fcoe_softc *fc, struct fc_frame *fp, u8 *sa)
715} 713}
716 714
717/** 715/**
718 * fcoe_watchdog - fcoe timer callback 716 * fcoe_watchdog() - fcoe timer callback
719 * @vp: 717 * @vp:
720 * 718 *
721 * This checks the pending queue length for fcoe and put fcoe to be paused state 719 * This checks the pending queue length for fcoe and set lport qfull
722 * if the FCOE_MAX_QUEUE_DEPTH is reached. This is done for all fc_lport on the 720 * if the FCOE_MAX_QUEUE_DEPTH is reached. This is done for all fc_lport on the
723 * fcoe_hostlist. 721 * fcoe_hostlist.
724 * 722 *
725 * Returns: 0 for success 723 * Returns: 0 for success
726 **/ 724 */
727void fcoe_watchdog(ulong vp) 725void fcoe_watchdog(ulong vp)
728{ 726{
729 struct fc_lport *lp;
730 struct fcoe_softc *fc; 727 struct fcoe_softc *fc;
731 int paused = 0;
732 728
733 read_lock(&fcoe_hostlist_lock); 729 read_lock(&fcoe_hostlist_lock);
734 list_for_each_entry(fc, &fcoe_hostlist, list) { 730 list_for_each_entry(fc, &fcoe_hostlist, list) {
735 lp = fc->lp; 731 if (fc->lp)
736 if (lp) { 732 fcoe_check_wait_queue(fc->lp);
737 if (fc->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH)
738 paused = 1;
739 if (fcoe_check_wait_queue(lp) < FCOE_MAX_QUEUE_DEPTH) {
740 if (paused)
741 fc_unpause(lp);
742 }
743 }
744 } 733 }
745 read_unlock(&fcoe_hostlist_lock); 734 read_unlock(&fcoe_hostlist_lock);
746 735
@@ -750,96 +739,64 @@ void fcoe_watchdog(ulong vp)
750 739
751 740
752/** 741/**
753 * fcoe_check_wait_queue - put the skb into fcoe pending xmit queue 742 * fcoe_check_wait_queue() - put the skb into fcoe pending xmit queue
754 * @lp: the fc_port for this skb 743 * @lp: the fc_port for this skb
755 * @skb: the associated skb to be xmitted 744 * @skb: the associated skb to be xmitted
756 * 745 *
757 * This empties the wait_queue, dequeue the head of the wait_queue queue 746 * This empties the wait_queue, dequeue the head of the wait_queue queue
758 * and calls fcoe_start_io() for each packet, if all skb have been 747 * and calls fcoe_start_io() for each packet, if all skb have been
759 * transmitted, return 0 if a error occurs, then restore wait_queue and 748 * transmitted, return qlen or -1 if a error occurs, then restore
760 * try again later. 749 * wait_queue and try again later.
761 * 750 *
762 * The wait_queue is used when the skb transmit fails. skb will go 751 * The wait_queue is used when the skb transmit fails. skb will go
763 * in the wait_queue which will be emptied by the time function OR 752 * in the wait_queue which will be emptied by the time function OR
764 * by the next skb transmit. 753 * by the next skb transmit.
765 * 754 *
766 * Returns: 0 for success 755 * Returns: 0 for success
767 **/ 756 */
768static int fcoe_check_wait_queue(struct fc_lport *lp) 757static int fcoe_check_wait_queue(struct fc_lport *lp)
769{ 758{
770 int rc, unpause = 0; 759 struct fcoe_softc *fc = lport_priv(lp);
771 int paused = 0;
772 struct sk_buff *skb; 760 struct sk_buff *skb;
773 struct fcoe_softc *fc; 761 int rc = -1;
774 762
775 fc = fcoe_softc(lp);
776 spin_lock_bh(&fc->fcoe_pending_queue.lock); 763 spin_lock_bh(&fc->fcoe_pending_queue.lock);
764 if (fc->fcoe_pending_queue_active)
765 goto out;
766 fc->fcoe_pending_queue_active = 1;
777 767
778 /* 768 while (fc->fcoe_pending_queue.qlen) {
779 * is this interface paused? 769 /* keep qlen > 0 until fcoe_start_io succeeds */
780 */ 770 fc->fcoe_pending_queue.qlen++;
781 if (fc->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH) 771 skb = __skb_dequeue(&fc->fcoe_pending_queue);
782 paused = 1;
783 if (fc->fcoe_pending_queue.qlen) {
784 while ((skb = __skb_dequeue(&fc->fcoe_pending_queue)) != NULL) {
785 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
786 rc = fcoe_start_io(skb);
787 if (rc) {
788 fcoe_insert_wait_queue_head(lp, skb);
789 return rc;
790 }
791 spin_lock_bh(&fc->fcoe_pending_queue.lock);
792 }
793 if (fc->fcoe_pending_queue.qlen < FCOE_MAX_QUEUE_DEPTH)
794 unpause = 1;
795 }
796 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
797 if ((unpause) && (paused))
798 fc_unpause(lp);
799 return fc->fcoe_pending_queue.qlen;
800}
801
802/**
803 * fcoe_insert_wait_queue_head - puts skb to fcoe pending queue head
804 * @lp: the fc_port for this skb
805 * @skb: the associated skb to be xmitted
806 *
807 * Returns: none
808 **/
809static void fcoe_insert_wait_queue_head(struct fc_lport *lp,
810 struct sk_buff *skb)
811{
812 struct fcoe_softc *fc;
813 772
814 fc = fcoe_softc(lp); 773 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
815 spin_lock_bh(&fc->fcoe_pending_queue.lock); 774 rc = fcoe_start_io(skb);
816 __skb_queue_head(&fc->fcoe_pending_queue, skb); 775 spin_lock_bh(&fc->fcoe_pending_queue.lock);
817 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
818}
819 776
820/** 777 if (rc) {
821 * fcoe_insert_wait_queue - put the skb into fcoe pending queue tail 778 __skb_queue_head(&fc->fcoe_pending_queue, skb);
822 * @lp: the fc_port for this skb 779 /* undo temporary increment above */
823 * @skb: the associated skb to be xmitted 780 fc->fcoe_pending_queue.qlen--;
824 * 781 break;
825 * Returns: none 782 }
826 **/ 783 /* undo temporary increment above */
827static void fcoe_insert_wait_queue(struct fc_lport *lp, 784 fc->fcoe_pending_queue.qlen--;
828 struct sk_buff *skb) 785 }
829{
830 struct fcoe_softc *fc;
831 786
832 fc = fcoe_softc(lp); 787 if (fc->fcoe_pending_queue.qlen < FCOE_LOW_QUEUE_DEPTH)
833 spin_lock_bh(&fc->fcoe_pending_queue.lock); 788 lp->qfull = 0;
834 __skb_queue_tail(&fc->fcoe_pending_queue, skb); 789 fc->fcoe_pending_queue_active = 0;
790 rc = fc->fcoe_pending_queue.qlen;
791out:
835 spin_unlock_bh(&fc->fcoe_pending_queue.lock); 792 spin_unlock_bh(&fc->fcoe_pending_queue.lock);
793 return rc;
836} 794}
837 795
838/** 796/**
839 * fcoe_dev_setup - setup link change notification interface 797 * fcoe_dev_setup() - setup link change notification interface
840 * 798 */
841 **/ 799static void fcoe_dev_setup()
842static void fcoe_dev_setup(void)
843{ 800{
844 /* 801 /*
845 * here setup a interface specific wd time to 802 * here setup a interface specific wd time to
@@ -849,15 +806,15 @@ static void fcoe_dev_setup(void)
849} 806}
850 807
851/** 808/**
852 * fcoe_dev_setup - cleanup link change notification interface 809 * fcoe_dev_setup() - cleanup link change notification interface
853 **/ 810 */
854static void fcoe_dev_cleanup(void) 811static void fcoe_dev_cleanup(void)
855{ 812{
856 unregister_netdevice_notifier(&fcoe_notifier); 813 unregister_netdevice_notifier(&fcoe_notifier);
857} 814}
858 815
859/** 816/**
860 * fcoe_device_notification - netdev event notification callback 817 * fcoe_device_notification() - netdev event notification callback
861 * @notifier: context of the notification 818 * @notifier: context of the notification
862 * @event: type of event 819 * @event: type of event
863 * @ptr: fixed array for output parsed ifname 820 * @ptr: fixed array for output parsed ifname
@@ -865,7 +822,7 @@ static void fcoe_dev_cleanup(void)
865 * This function is called by the ethernet driver in case of link change event 822 * This function is called by the ethernet driver in case of link change event
866 * 823 *
867 * Returns: 0 for success 824 * Returns: 0 for success
868 **/ 825 */
869static int fcoe_device_notification(struct notifier_block *notifier, 826static int fcoe_device_notification(struct notifier_block *notifier,
870 ulong event, void *ptr) 827 ulong event, void *ptr)
871{ 828{
@@ -873,7 +830,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,
873 struct net_device *real_dev = ptr; 830 struct net_device *real_dev = ptr;
874 struct fcoe_softc *fc; 831 struct fcoe_softc *fc;
875 struct fcoe_dev_stats *stats; 832 struct fcoe_dev_stats *stats;
876 u16 new_status; 833 u32 new_link_up;
877 u32 mfs; 834 u32 mfs;
878 int rc = NOTIFY_OK; 835 int rc = NOTIFY_OK;
879 836
@@ -890,17 +847,15 @@ static int fcoe_device_notification(struct notifier_block *notifier,
890 goto out; 847 goto out;
891 } 848 }
892 849
893 new_status = lp->link_status; 850 new_link_up = lp->link_up;
894 switch (event) { 851 switch (event) {
895 case NETDEV_DOWN: 852 case NETDEV_DOWN:
896 case NETDEV_GOING_DOWN: 853 case NETDEV_GOING_DOWN:
897 new_status &= ~FC_LINK_UP; 854 new_link_up = 0;
898 break; 855 break;
899 case NETDEV_UP: 856 case NETDEV_UP:
900 case NETDEV_CHANGE: 857 case NETDEV_CHANGE:
901 new_status &= ~FC_LINK_UP; 858 new_link_up = !fcoe_link_ok(lp);
902 if (!fcoe_link_ok(lp))
903 new_status |= FC_LINK_UP;
904 break; 859 break;
905 case NETDEV_CHANGEMTU: 860 case NETDEV_CHANGEMTU:
906 mfs = fc->real_dev->mtu - 861 mfs = fc->real_dev->mtu -
@@ -908,17 +863,15 @@ static int fcoe_device_notification(struct notifier_block *notifier,
908 sizeof(struct fcoe_crc_eof)); 863 sizeof(struct fcoe_crc_eof));
909 if (mfs >= FC_MIN_MAX_FRAME) 864 if (mfs >= FC_MIN_MAX_FRAME)
910 fc_set_mfs(lp, mfs); 865 fc_set_mfs(lp, mfs);
911 new_status &= ~FC_LINK_UP; 866 new_link_up = !fcoe_link_ok(lp);
912 if (!fcoe_link_ok(lp))
913 new_status |= FC_LINK_UP;
914 break; 867 break;
915 case NETDEV_REGISTER: 868 case NETDEV_REGISTER:
916 break; 869 break;
917 default: 870 default:
918 FC_DBG("unknown event %ld call", event); 871 FC_DBG("unknown event %ld call", event);
919 } 872 }
920 if (lp->link_status != new_status) { 873 if (lp->link_up != new_link_up) {
921 if ((new_status & FC_LINK_UP) == FC_LINK_UP) 874 if (new_link_up)
922 fc_linkup(lp); 875 fc_linkup(lp);
923 else { 876 else {
924 stats = lp->dev_stats[smp_processor_id()]; 877 stats = lp->dev_stats[smp_processor_id()];
@@ -933,12 +886,12 @@ out:
933} 886}
934 887
935/** 888/**
936 * fcoe_if_to_netdev - parse a name buffer to get netdev 889 * fcoe_if_to_netdev() - parse a name buffer to get netdev
937 * @ifname: fixed array for output parsed ifname 890 * @ifname: fixed array for output parsed ifname
938 * @buffer: incoming buffer to be copied 891 * @buffer: incoming buffer to be copied
939 * 892 *
940 * Returns: NULL or ptr to netdeive 893 * Returns: NULL or ptr to netdeive
941 **/ 894 */
942static struct net_device *fcoe_if_to_netdev(const char *buffer) 895static struct net_device *fcoe_if_to_netdev(const char *buffer)
943{ 896{
944 char *cp; 897 char *cp;
@@ -955,13 +908,13 @@ static struct net_device *fcoe_if_to_netdev(const char *buffer)
955} 908}
956 909
957/** 910/**
958 * fcoe_netdev_to_module_owner - finds out the nic drive moddule of the netdev 911 * fcoe_netdev_to_module_owner() - finds out the nic drive moddule of the netdev
959 * @netdev: the target netdev 912 * @netdev: the target netdev
960 * 913 *
961 * Returns: ptr to the struct module, NULL for failure 914 * Returns: ptr to the struct module, NULL for failure
962 **/ 915 */
963static struct module *fcoe_netdev_to_module_owner( 916static struct module *
964 const struct net_device *netdev) 917fcoe_netdev_to_module_owner(const struct net_device *netdev)
965{ 918{
966 struct device *dev; 919 struct device *dev;
967 920
@@ -979,12 +932,14 @@ static struct module *fcoe_netdev_to_module_owner(
979} 932}
980 933
981/** 934/**
982 * fcoe_ethdrv_get - holds the nic driver module by try_module_get() for 935 * fcoe_ethdrv_get() - Hold the Ethernet driver
983 * the corresponding netdev.
984 * @netdev: the target netdev 936 * @netdev: the target netdev
985 * 937 *
938 * Holds the Ethernet driver module by try_module_get() for
939 * the corresponding netdev.
940 *
986 * Returns: 0 for succsss 941 * Returns: 0 for succsss
987 **/ 942 */
988static int fcoe_ethdrv_get(const struct net_device *netdev) 943static int fcoe_ethdrv_get(const struct net_device *netdev)
989{ 944{
990 struct module *owner; 945 struct module *owner;
@@ -999,12 +954,14 @@ static int fcoe_ethdrv_get(const struct net_device *netdev)
999} 954}
1000 955
1001/** 956/**
1002 * fcoe_ethdrv_get - releases the nic driver module by module_put for 957 * fcoe_ethdrv_put() - Release the Ethernet driver
1003 * the corresponding netdev.
1004 * @netdev: the target netdev 958 * @netdev: the target netdev
1005 * 959 *
960 * Releases the Ethernet driver module by module_put for
961 * the corresponding netdev.
962 *
1006 * Returns: 0 for succsss 963 * Returns: 0 for succsss
1007 **/ 964 */
1008static int fcoe_ethdrv_put(const struct net_device *netdev) 965static int fcoe_ethdrv_put(const struct net_device *netdev)
1009{ 966{
1010 struct module *owner; 967 struct module *owner;
@@ -1020,12 +977,12 @@ static int fcoe_ethdrv_put(const struct net_device *netdev)
1020} 977}
1021 978
1022/** 979/**
1023 * fcoe_destroy- handles the destroy from sysfs 980 * fcoe_destroy() - handles the destroy from sysfs
1024 * @buffer: expcted to be a eth if name 981 * @buffer: expcted to be a eth if name
1025 * @kp: associated kernel param 982 * @kp: associated kernel param
1026 * 983 *
1027 * Returns: 0 for success 984 * Returns: 0 for success
1028 **/ 985 */
1029static int fcoe_destroy(const char *buffer, struct kernel_param *kp) 986static int fcoe_destroy(const char *buffer, struct kernel_param *kp)
1030{ 987{
1031 int rc; 988 int rc;
@@ -1058,12 +1015,12 @@ out_nodev:
1058} 1015}
1059 1016
1060/** 1017/**
1061 * fcoe_create - handles the create call from sysfs 1018 * fcoe_create() - Handles the create call from sysfs
1062 * @buffer: expcted to be a eth if name 1019 * @buffer: expcted to be a eth if name
1063 * @kp: associated kernel param 1020 * @kp: associated kernel param
1064 * 1021 *
1065 * Returns: 0 for success 1022 * Returns: 0 for success
1066 **/ 1023 */
1067static int fcoe_create(const char *buffer, struct kernel_param *kp) 1024static int fcoe_create(const char *buffer, struct kernel_param *kp)
1068{ 1025{
1069 int rc; 1026 int rc;
@@ -1104,8 +1061,8 @@ module_param_call(destroy, fcoe_destroy, NULL, NULL, S_IWUSR);
1104__MODULE_PARM_TYPE(destroy, "string"); 1061__MODULE_PARM_TYPE(destroy, "string");
1105MODULE_PARM_DESC(destroy, "Destroy fcoe port"); 1062MODULE_PARM_DESC(destroy, "Destroy fcoe port");
1106 1063
1107/* 1064/**
1108 * fcoe_link_ok - check if link is ok for the fc_lport 1065 * fcoe_link_ok() - Check if link is ok for the fc_lport
1109 * @lp: ptr to the fc_lport 1066 * @lp: ptr to the fc_lport
1110 * 1067 *
1111 * Any permanently-disqualifying conditions have been previously checked. 1068 * Any permanently-disqualifying conditions have been previously checked.
@@ -1120,7 +1077,7 @@ MODULE_PARM_DESC(destroy, "Destroy fcoe port");
1120 */ 1077 */
1121int fcoe_link_ok(struct fc_lport *lp) 1078int fcoe_link_ok(struct fc_lport *lp)
1122{ 1079{
1123 struct fcoe_softc *fc = fcoe_softc(lp); 1080 struct fcoe_softc *fc = lport_priv(lp);
1124 struct net_device *dev = fc->real_dev; 1081 struct net_device *dev = fc->real_dev;
1125 struct ethtool_cmd ecmd = { ETHTOOL_GSET }; 1082 struct ethtool_cmd ecmd = { ETHTOOL_GSET };
1126 int rc = 0; 1083 int rc = 0;
@@ -1149,9 +1106,8 @@ int fcoe_link_ok(struct fc_lport *lp)
1149} 1106}
1150EXPORT_SYMBOL_GPL(fcoe_link_ok); 1107EXPORT_SYMBOL_GPL(fcoe_link_ok);
1151 1108
1152/* 1109/**
1153 * fcoe_percpu_clean - frees skb of the corresponding lport from the per 1110 * fcoe_percpu_clean() - Clear the pending skbs for an lport
1154 * cpu queue.
1155 * @lp: the fc_lport 1111 * @lp: the fc_lport
1156 */ 1112 */
1157void fcoe_percpu_clean(struct fc_lport *lp) 1113void fcoe_percpu_clean(struct fc_lport *lp)
@@ -1185,11 +1141,11 @@ void fcoe_percpu_clean(struct fc_lport *lp)
1185EXPORT_SYMBOL_GPL(fcoe_percpu_clean); 1141EXPORT_SYMBOL_GPL(fcoe_percpu_clean);
1186 1142
1187/** 1143/**
1188 * fcoe_clean_pending_queue - dequeue skb and free it 1144 * fcoe_clean_pending_queue() - Dequeue a skb and free it
1189 * @lp: the corresponding fc_lport 1145 * @lp: the corresponding fc_lport
1190 * 1146 *
1191 * Returns: none 1147 * Returns: none
1192 **/ 1148 */
1193void fcoe_clean_pending_queue(struct fc_lport *lp) 1149void fcoe_clean_pending_queue(struct fc_lport *lp)
1194{ 1150{
1195 struct fcoe_softc *fc = lport_priv(lp); 1151 struct fcoe_softc *fc = lport_priv(lp);
@@ -1206,21 +1162,21 @@ void fcoe_clean_pending_queue(struct fc_lport *lp)
1206EXPORT_SYMBOL_GPL(fcoe_clean_pending_queue); 1162EXPORT_SYMBOL_GPL(fcoe_clean_pending_queue);
1207 1163
1208/** 1164/**
1209 * libfc_host_alloc - allocate a Scsi_Host with room for the fc_lport 1165 * libfc_host_alloc() - Allocate a Scsi_Host with room for the fc_lport
1210 * @sht: ptr to the scsi host templ 1166 * @sht: ptr to the scsi host templ
1211 * @priv_size: size of private data after fc_lport 1167 * @priv_size: size of private data after fc_lport
1212 * 1168 *
1213 * Returns: ptr to Scsi_Host 1169 * Returns: ptr to Scsi_Host
1214 * TODO - to libfc? 1170 * TODO: to libfc?
1215 */ 1171 */
1216static inline struct Scsi_Host *libfc_host_alloc( 1172static inline struct Scsi_Host *
1217 struct scsi_host_template *sht, int priv_size) 1173libfc_host_alloc(struct scsi_host_template *sht, int priv_size)
1218{ 1174{
1219 return scsi_host_alloc(sht, sizeof(struct fc_lport) + priv_size); 1175 return scsi_host_alloc(sht, sizeof(struct fc_lport) + priv_size);
1220} 1176}
1221 1177
1222/** 1178/**
1223 * fcoe_host_alloc - allocate a Scsi_Host with room for the fcoe_softc 1179 * fcoe_host_alloc() - Allocate a Scsi_Host with room for the fcoe_softc
1224 * @sht: ptr to the scsi host templ 1180 * @sht: ptr to the scsi host templ
1225 * @priv_size: size of private data after fc_lport 1181 * @priv_size: size of private data after fc_lport
1226 * 1182 *
@@ -1232,8 +1188,8 @@ struct Scsi_Host *fcoe_host_alloc(struct scsi_host_template *sht, int priv_size)
1232} 1188}
1233EXPORT_SYMBOL_GPL(fcoe_host_alloc); 1189EXPORT_SYMBOL_GPL(fcoe_host_alloc);
1234 1190
1235/* 1191/**
1236 * fcoe_reset - resets the fcoe 1192 * fcoe_reset() - Resets the fcoe
1237 * @shost: shost the reset is from 1193 * @shost: shost the reset is from
1238 * 1194 *
1239 * Returns: always 0 1195 * Returns: always 0
@@ -1246,8 +1202,8 @@ int fcoe_reset(struct Scsi_Host *shost)
1246} 1202}
1247EXPORT_SYMBOL_GPL(fcoe_reset); 1203EXPORT_SYMBOL_GPL(fcoe_reset);
1248 1204
1249/* 1205/**
1250 * fcoe_wwn_from_mac - converts 48-bit IEEE MAC address to 64-bit FC WWN. 1206 * fcoe_wwn_from_mac() - Converts 48-bit IEEE MAC address to 64-bit FC WWN.
1251 * @mac: mac address 1207 * @mac: mac address
1252 * @scheme: check port 1208 * @scheme: check port
1253 * @port: port indicator for converting 1209 * @port: port indicator for converting
@@ -1286,14 +1242,15 @@ u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN],
1286 return wwn; 1242 return wwn;
1287} 1243}
1288EXPORT_SYMBOL_GPL(fcoe_wwn_from_mac); 1244EXPORT_SYMBOL_GPL(fcoe_wwn_from_mac);
1289/* 1245
1290 * fcoe_hostlist_lookup_softc - find the corresponding lport by a given device 1246/**
1247 * fcoe_hostlist_lookup_softc() - find the corresponding lport by a given device
1291 * @device: this is currently ptr to net_device 1248 * @device: this is currently ptr to net_device
1292 * 1249 *
1293 * Returns: NULL or the located fcoe_softc 1250 * Returns: NULL or the located fcoe_softc
1294 */ 1251 */
1295static struct fcoe_softc *fcoe_hostlist_lookup_softc( 1252static struct fcoe_softc *
1296 const struct net_device *dev) 1253fcoe_hostlist_lookup_softc(const struct net_device *dev)
1297{ 1254{
1298 struct fcoe_softc *fc; 1255 struct fcoe_softc *fc;
1299 1256
@@ -1308,8 +1265,8 @@ static struct fcoe_softc *fcoe_hostlist_lookup_softc(
1308 return NULL; 1265 return NULL;
1309} 1266}
1310 1267
1311/* 1268/**
1312 * fcoe_hostlist_lookup - find the corresponding lport by netdev 1269 * fcoe_hostlist_lookup() - Find the corresponding lport by netdev
1313 * @netdev: ptr to net_device 1270 * @netdev: ptr to net_device
1314 * 1271 *
1315 * Returns: 0 for success 1272 * Returns: 0 for success
@@ -1324,8 +1281,8 @@ struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
1324} 1281}
1325EXPORT_SYMBOL_GPL(fcoe_hostlist_lookup); 1282EXPORT_SYMBOL_GPL(fcoe_hostlist_lookup);
1326 1283
1327/* 1284/**
1328 * fcoe_hostlist_add - add a lport to lports list 1285 * fcoe_hostlist_add() - Add a lport to lports list
1329 * @lp: ptr to the fc_lport to badded 1286 * @lp: ptr to the fc_lport to badded
1330 * 1287 *
1331 * Returns: 0 for success 1288 * Returns: 0 for success
@@ -1336,7 +1293,7 @@ int fcoe_hostlist_add(const struct fc_lport *lp)
1336 1293
1337 fc = fcoe_hostlist_lookup_softc(fcoe_netdev(lp)); 1294 fc = fcoe_hostlist_lookup_softc(fcoe_netdev(lp));
1338 if (!fc) { 1295 if (!fc) {
1339 fc = fcoe_softc(lp); 1296 fc = lport_priv(lp);
1340 write_lock_bh(&fcoe_hostlist_lock); 1297 write_lock_bh(&fcoe_hostlist_lock);
1341 list_add_tail(&fc->list, &fcoe_hostlist); 1298 list_add_tail(&fc->list, &fcoe_hostlist);
1342 write_unlock_bh(&fcoe_hostlist_lock); 1299 write_unlock_bh(&fcoe_hostlist_lock);
@@ -1345,8 +1302,8 @@ int fcoe_hostlist_add(const struct fc_lport *lp)
1345} 1302}
1346EXPORT_SYMBOL_GPL(fcoe_hostlist_add); 1303EXPORT_SYMBOL_GPL(fcoe_hostlist_add);
1347 1304
1348/* 1305/**
1349 * fcoe_hostlist_remove - remove a lport from lports list 1306 * fcoe_hostlist_remove() - remove a lport from lports list
1350 * @lp: ptr to the fc_lport to badded 1307 * @lp: ptr to the fc_lport to badded
1351 * 1308 *
1352 * Returns: 0 for success 1309 * Returns: 0 for success
@@ -1366,12 +1323,12 @@ int fcoe_hostlist_remove(const struct fc_lport *lp)
1366EXPORT_SYMBOL_GPL(fcoe_hostlist_remove); 1323EXPORT_SYMBOL_GPL(fcoe_hostlist_remove);
1367 1324
1368/** 1325/**
1369 * fcoe_libfc_config - sets up libfc related properties for lport 1326 * fcoe_libfc_config() - sets up libfc related properties for lport
1370 * @lp: ptr to the fc_lport 1327 * @lp: ptr to the fc_lport
1371 * @tt: libfc function template 1328 * @tt: libfc function template
1372 * 1329 *
1373 * Returns : 0 for success 1330 * Returns : 0 for success
1374 **/ 1331 */
1375int fcoe_libfc_config(struct fc_lport *lp, struct libfc_function_template *tt) 1332int fcoe_libfc_config(struct fc_lport *lp, struct libfc_function_template *tt)
1376{ 1333{
1377 /* Set the function pointers set by the LLDD */ 1334 /* Set the function pointers set by the LLDD */
@@ -1389,14 +1346,14 @@ int fcoe_libfc_config(struct fc_lport *lp, struct libfc_function_template *tt)
1389EXPORT_SYMBOL_GPL(fcoe_libfc_config); 1346EXPORT_SYMBOL_GPL(fcoe_libfc_config);
1390 1347
1391/** 1348/**
1392 * fcoe_init - fcoe module loading initialization 1349 * fcoe_init() - fcoe module loading initialization
1393 * 1350 *
1394 * Initialization routine 1351 * Initialization routine
1395 * 1. Will create fc transport software structure 1352 * 1. Will create fc transport software structure
1396 * 2. initialize the link list of port information structure 1353 * 2. initialize the link list of port information structure
1397 * 1354 *
1398 * Returns 0 on success, negative on failure 1355 * Returns 0 on success, negative on failure
1399 **/ 1356 */
1400static int __init fcoe_init(void) 1357static int __init fcoe_init(void)
1401{ 1358{
1402 int cpu; 1359 int cpu;
@@ -1433,7 +1390,6 @@ static int __init fcoe_init(void)
1433 } else { 1390 } else {
1434 fcoe_percpu[cpu] = NULL; 1391 fcoe_percpu[cpu] = NULL;
1435 kfree(p); 1392 kfree(p);
1436
1437 } 1393 }
1438 } 1394 }
1439 } 1395 }
@@ -1443,11 +1399,9 @@ static int __init fcoe_init(void)
1443 */ 1399 */
1444 fcoe_dev_setup(); 1400 fcoe_dev_setup();
1445 1401
1446 init_timer(&fcoe_timer); 1402 setup_timer(&fcoe_timer, fcoe_watchdog, 0);
1447 fcoe_timer.data = 0; 1403
1448 fcoe_timer.function = fcoe_watchdog; 1404 mod_timer(&fcoe_timer, jiffies + (10 * HZ));
1449 fcoe_timer.expires = (jiffies + (10 * HZ));
1450 add_timer(&fcoe_timer);
1451 1405
1452 /* initiatlize the fcoe transport */ 1406 /* initiatlize the fcoe transport */
1453 fcoe_transport_init(); 1407 fcoe_transport_init();
@@ -1459,10 +1413,10 @@ static int __init fcoe_init(void)
1459module_init(fcoe_init); 1413module_init(fcoe_init);
1460 1414
1461/** 1415/**
1462 * fcoe_exit - fcoe module unloading cleanup 1416 * fcoe_exit() - fcoe module unloading cleanup
1463 * 1417 *
1464 * Returns 0 on success, negative on failure 1418 * Returns 0 on success, negative on failure
1465 **/ 1419 */
1466static void __exit fcoe_exit(void) 1420static void __exit fcoe_exit(void)
1467{ 1421{
1468 u32 idx; 1422 u32 idx;
@@ -1483,7 +1437,7 @@ static void __exit fcoe_exit(void)
1483 */ 1437 */
1484 del_timer_sync(&fcoe_timer); 1438 del_timer_sync(&fcoe_timer);
1485 1439
1486 /* releases the assocaited fcoe transport for each lport */ 1440 /* releases the associated fcoe transport for each lport */
1487 list_for_each_entry_safe(fc, tmp, &fcoe_hostlist, list) 1441 list_for_each_entry_safe(fc, tmp, &fcoe_hostlist, list)
1488 fcoe_transport_release(fc->real_dev); 1442 fcoe_transport_release(fc->real_dev);
1489 1443