diff options
author | Robert Love <robert.w.love@intel.com> | 2009-11-03 14:47:50 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-12-04 13:01:08 -0500 |
commit | 1875f27e291d05711f15a8a3d486abfeaf385931 (patch) | |
tree | 7eb368cbc6fcec3a3859c2da092e79daf3bd68d2 | |
parent | 70b51aabf3b03fbf8d61c14847ccce4c69fb0cdd (diff) |
[SCSI] fcoe: Formatting cleanups and commenting
Added kernel-doc comment blocks to all structures and functions.
Renamed fc_lport instances rom lp to lport to be inline with our
naming convention.
Renamed all misnamed net_device instances to netdev to be inline
with our naming convention.
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r-- | drivers/scsi/fcoe/fcoe.c | 722 | ||||
-rw-r--r-- | drivers/scsi/fcoe/fcoe.h | 75 |
2 files changed, 441 insertions, 356 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 8f078d306a0a..5615dfe10bf5 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c | |||
@@ -66,14 +66,14 @@ LIST_HEAD(fcoe_hostlist); | |||
66 | DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu); | 66 | DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu); |
67 | 67 | ||
68 | /* Function Prototypes */ | 68 | /* Function Prototypes */ |
69 | static int fcoe_reset(struct Scsi_Host *shost); | 69 | static int fcoe_reset(struct Scsi_Host *); |
70 | static int fcoe_xmit(struct fc_lport *, struct fc_frame *); | 70 | static int fcoe_xmit(struct fc_lport *, struct fc_frame *); |
71 | static int fcoe_rcv(struct sk_buff *, struct net_device *, | 71 | static int fcoe_rcv(struct sk_buff *, struct net_device *, |
72 | struct packet_type *, struct net_device *); | 72 | struct packet_type *, struct net_device *); |
73 | static int fcoe_percpu_receive_thread(void *arg); | 73 | static int fcoe_percpu_receive_thread(void *); |
74 | static void fcoe_clean_pending_queue(struct fc_lport *lp); | 74 | static void fcoe_clean_pending_queue(struct fc_lport *); |
75 | static void fcoe_percpu_clean(struct fc_lport *lp); | 75 | static void fcoe_percpu_clean(struct fc_lport *); |
76 | static int fcoe_link_ok(struct fc_lport *lp); | 76 | static int fcoe_link_ok(struct fc_lport *); |
77 | 77 | ||
78 | static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *); | 78 | static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *); |
79 | static int fcoe_hostlist_add(const struct fc_lport *); | 79 | static int fcoe_hostlist_add(const struct fc_lport *); |
@@ -82,21 +82,68 @@ static void fcoe_check_wait_queue(struct fc_lport *, struct sk_buff *); | |||
82 | static int fcoe_device_notification(struct notifier_block *, ulong, void *); | 82 | static int fcoe_device_notification(struct notifier_block *, ulong, void *); |
83 | static void fcoe_dev_setup(void); | 83 | static void fcoe_dev_setup(void); |
84 | static void fcoe_dev_cleanup(void); | 84 | static void fcoe_dev_cleanup(void); |
85 | static struct fcoe_interface * | 85 | static struct fcoe_interface |
86 | fcoe_hostlist_lookup_port(const struct net_device *dev); | 86 | *fcoe_hostlist_lookup_port(const struct net_device *); |
87 | |||
88 | static int fcoe_fip_recv(struct sk_buff *, struct net_device *, | ||
89 | struct packet_type *, struct net_device *); | ||
90 | |||
91 | static void fcoe_fip_send(struct fcoe_ctlr *, struct sk_buff *); | ||
92 | static void fcoe_update_src_mac(struct fc_lport *, u8 *); | ||
93 | static u8 *fcoe_get_src_mac(struct fc_lport *); | ||
94 | static void fcoe_destroy_work(struct work_struct *); | ||
95 | |||
96 | static int fcoe_ddp_setup(struct fc_lport *, u16, struct scatterlist *, | ||
97 | unsigned int); | ||
98 | static int fcoe_ddp_done(struct fc_lport *, u16); | ||
99 | |||
100 | static int fcoe_cpu_callback(struct notifier_block *, unsigned long, void *); | ||
101 | |||
102 | static int fcoe_create(const char *, struct kernel_param *); | ||
103 | static int fcoe_destroy(const char *, struct kernel_param *); | ||
104 | |||
105 | static u8 *fcoe_get_src_mac(struct fc_lport *); | ||
106 | static void fcoe_destroy_work(struct work_struct *); | ||
87 | 107 | ||
88 | /* notification function from net device */ | 108 | static struct fc_seq *fcoe_elsct_send(struct fc_lport *, |
109 | u32 did, struct fc_frame *, | ||
110 | unsigned int op, | ||
111 | void (*resp)(struct fc_seq *, | ||
112 | struct fc_frame *, | ||
113 | void *), | ||
114 | void *, u32 timeout); | ||
115 | |||
116 | module_param_call(create, fcoe_create, NULL, NULL, S_IWUSR); | ||
117 | __MODULE_PARM_TYPE(create, "string"); | ||
118 | MODULE_PARM_DESC(create, "Create fcoe fcoe using net device passed in."); | ||
119 | module_param_call(destroy, fcoe_destroy, NULL, NULL, S_IWUSR); | ||
120 | __MODULE_PARM_TYPE(destroy, "string"); | ||
121 | MODULE_PARM_DESC(destroy, "Destroy fcoe fcoe"); | ||
122 | |||
123 | /* notification function for packets from net device */ | ||
89 | static struct notifier_block fcoe_notifier = { | 124 | static struct notifier_block fcoe_notifier = { |
90 | .notifier_call = fcoe_device_notification, | 125 | .notifier_call = fcoe_device_notification, |
91 | }; | 126 | }; |
92 | 127 | ||
128 | /* notification function for CPU hotplug events */ | ||
129 | static struct notifier_block fcoe_cpu_notifier = { | ||
130 | .notifier_call = fcoe_cpu_callback, | ||
131 | }; | ||
132 | |||
93 | static struct scsi_transport_template *fcoe_transport_template; | 133 | static struct scsi_transport_template *fcoe_transport_template; |
94 | static struct scsi_transport_template *fcoe_vport_transport_template; | 134 | static struct scsi_transport_template *fcoe_vport_transport_template; |
95 | 135 | ||
96 | static int fcoe_vport_destroy(struct fc_vport *vport); | 136 | static int fcoe_vport_destroy(struct fc_vport *); |
97 | static int fcoe_vport_create(struct fc_vport *vport, bool disabled); | 137 | static int fcoe_vport_create(struct fc_vport *, bool disabled); |
98 | static int fcoe_vport_disable(struct fc_vport *vport, bool disable); | 138 | static int fcoe_vport_disable(struct fc_vport *, bool disable); |
99 | static void fcoe_set_vport_symbolic_name(struct fc_vport *vport); | 139 | static void fcoe_set_vport_symbolic_name(struct fc_vport *); |
140 | |||
141 | static struct libfc_function_template fcoe_libfc_fcn_templ = { | ||
142 | .frame_send = fcoe_xmit, | ||
143 | .ddp_setup = fcoe_ddp_setup, | ||
144 | .ddp_done = fcoe_ddp_done, | ||
145 | .elsct_send = fcoe_elsct_send, | ||
146 | }; | ||
100 | 147 | ||
101 | struct fc_function_template fcoe_transport_function = { | 148 | struct fc_function_template fcoe_transport_function = { |
102 | .show_host_node_name = 1, | 149 | .show_host_node_name = 1, |
@@ -192,13 +239,10 @@ static struct scsi_host_template fcoe_shost_template = { | |||
192 | .max_sectors = 0xffff, | 239 | .max_sectors = 0xffff, |
193 | }; | 240 | }; |
194 | 241 | ||
195 | static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev, | ||
196 | struct packet_type *ptype, | ||
197 | struct net_device *orig_dev); | ||
198 | /** | 242 | /** |
199 | * fcoe_interface_setup() | 243 | * fcoe_interface_setup() - Setup a FCoE interface |
200 | * @fcoe: new fcoe_interface | 244 | * @fcoe: The new FCoE interface |
201 | * @netdev : ptr to the associated netdevice struct | 245 | * @netdev: The net device that the fcoe interface is on |
202 | * | 246 | * |
203 | * Returns : 0 for success | 247 | * Returns : 0 for success |
204 | * Locking: must be called with the RTNL mutex held | 248 | * Locking: must be called with the RTNL mutex held |
@@ -273,14 +317,9 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe, | |||
273 | return 0; | 317 | return 0; |
274 | } | 318 | } |
275 | 319 | ||
276 | static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb); | ||
277 | static void fcoe_update_src_mac(struct fc_lport *lport, u8 *addr); | ||
278 | static u8 *fcoe_get_src_mac(struct fc_lport *lport); | ||
279 | static void fcoe_destroy_work(struct work_struct *work); | ||
280 | |||
281 | /** | 320 | /** |
282 | * fcoe_interface_create() | 321 | * fcoe_interface_create() - Create a FCoE interface on a net device |
283 | * @netdev: network interface | 322 | * @netdev: The net device to create the FCoE interface on |
284 | * | 323 | * |
285 | * Returns: pointer to a struct fcoe_interface or NULL on error | 324 | * Returns: pointer to a struct fcoe_interface or NULL on error |
286 | */ | 325 | */ |
@@ -311,8 +350,8 @@ static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev) | |||
311 | } | 350 | } |
312 | 351 | ||
313 | /** | 352 | /** |
314 | * fcoe_interface_cleanup() - clean up netdev configurations | 353 | * fcoe_interface_cleanup() - Clean up a FCoE interface |
315 | * @fcoe: | 354 | * @fcoe: The FCoE interface to be cleaned up |
316 | * | 355 | * |
317 | * Caller must be holding the RTNL mutex | 356 | * Caller must be holding the RTNL mutex |
318 | */ | 357 | */ |
@@ -351,7 +390,7 @@ void fcoe_interface_cleanup(struct fcoe_interface *fcoe) | |||
351 | 390 | ||
352 | /** | 391 | /** |
353 | * fcoe_interface_release() - fcoe_port kref release function | 392 | * fcoe_interface_release() - fcoe_port kref release function |
354 | * @kref: embedded reference count in an fcoe_interface struct | 393 | * @kref: Embedded reference count in an fcoe_interface struct |
355 | */ | 394 | */ |
356 | static void fcoe_interface_release(struct kref *kref) | 395 | static void fcoe_interface_release(struct kref *kref) |
357 | { | 396 | { |
@@ -367,8 +406,8 @@ static void fcoe_interface_release(struct kref *kref) | |||
367 | } | 406 | } |
368 | 407 | ||
369 | /** | 408 | /** |
370 | * fcoe_interface_get() | 409 | * fcoe_interface_get() - Get a reference to a FCoE interface |
371 | * @fcoe: | 410 | * @fcoe: The FCoE interface to be held |
372 | */ | 411 | */ |
373 | static inline void fcoe_interface_get(struct fcoe_interface *fcoe) | 412 | static inline void fcoe_interface_get(struct fcoe_interface *fcoe) |
374 | { | 413 | { |
@@ -376,8 +415,8 @@ static inline void fcoe_interface_get(struct fcoe_interface *fcoe) | |||
376 | } | 415 | } |
377 | 416 | ||
378 | /** | 417 | /** |
379 | * fcoe_interface_put() | 418 | * fcoe_interface_put() - Put a reference to a FCoE interface |
380 | * @fcoe: | 419 | * @fcoe: The FCoE interface to be released |
381 | */ | 420 | */ |
382 | static inline void fcoe_interface_put(struct fcoe_interface *fcoe) | 421 | static inline void fcoe_interface_put(struct fcoe_interface *fcoe) |
383 | { | 422 | { |
@@ -385,15 +424,16 @@ static inline void fcoe_interface_put(struct fcoe_interface *fcoe) | |||
385 | } | 424 | } |
386 | 425 | ||
387 | /** | 426 | /** |
388 | * fcoe_fip_recv - handle a received FIP frame. | 427 | * fcoe_fip_recv() - Handler for received FIP frames |
389 | * @skb: the receive skb | 428 | * @skb: The receive skb |
390 | * @dev: associated &net_device | 429 | * @netdev: The associated net device |
391 | * @ptype: the &packet_type structure which was used to register this handler. | 430 | * @ptype: The packet_type structure which was used to register this handler |
392 | * @orig_dev: original receive &net_device, in case @dev is a bond. | 431 | * @orig_dev: The original net_device the the skb was received on. |
432 | * (in case dev is a bond) | ||
393 | * | 433 | * |
394 | * Returns: 0 for success | 434 | * Returns: 0 for success |
395 | */ | 435 | */ |
396 | static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev, | 436 | static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *netdev, |
397 | struct packet_type *ptype, | 437 | struct packet_type *ptype, |
398 | struct net_device *orig_dev) | 438 | struct net_device *orig_dev) |
399 | { | 439 | { |
@@ -405,9 +445,9 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev, | |||
405 | } | 445 | } |
406 | 446 | ||
407 | /** | 447 | /** |
408 | * fcoe_fip_send() - send an Ethernet-encapsulated FIP frame. | 448 | * fcoe_fip_send() - Send an Ethernet-encapsulated FIP frame |
409 | * @fip: FCoE controller. | 449 | * @fip: The FCoE controller |
410 | * @skb: FIP Packet. | 450 | * @skb: The FIP packet to be sent |
411 | */ | 451 | */ |
412 | static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb) | 452 | static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb) |
413 | { | 453 | { |
@@ -416,9 +456,9 @@ static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb) | |||
416 | } | 456 | } |
417 | 457 | ||
418 | /** | 458 | /** |
419 | * fcoe_update_src_mac() - Update Ethernet MAC filters. | 459 | * fcoe_update_src_mac() - Update the Ethernet MAC filters |
420 | * @lport: libfc lport | 460 | * @lport: The local port to update the source MAC on |
421 | * @addr: Unicast MAC address to add. | 461 | * @addr: Unicast MAC address to add |
422 | * | 462 | * |
423 | * Remove any previously-set unicast MAC filter. | 463 | * Remove any previously-set unicast MAC filter. |
424 | * Add secondary FCoE MAC address filter for our OUI. | 464 | * Add secondary FCoE MAC address filter for our OUI. |
@@ -449,60 +489,59 @@ static u8 *fcoe_get_src_mac(struct fc_lport *lport) | |||
449 | } | 489 | } |
450 | 490 | ||
451 | /** | 491 | /** |
452 | * fcoe_lport_config() - sets up the fc_lport | 492 | * fcoe_lport_config() - Set up a local port |
453 | * @lp: ptr to the fc_lport | 493 | * @lport: The local port to be setup |
454 | * | 494 | * |
455 | * Returns: 0 for success | 495 | * Returns: 0 for success |
456 | */ | 496 | */ |
457 | static int fcoe_lport_config(struct fc_lport *lp) | 497 | static int fcoe_lport_config(struct fc_lport *lport) |
458 | { | 498 | { |
459 | lp->link_up = 0; | 499 | lport->link_up = 0; |
460 | lp->qfull = 0; | 500 | lport->qfull = 0; |
461 | lp->max_retry_count = 3; | 501 | lport->max_retry_count = 3; |
462 | lp->max_rport_retry_count = 3; | 502 | lport->max_rport_retry_count = 3; |
463 | lp->e_d_tov = 2 * 1000; /* FC-FS default */ | 503 | lport->e_d_tov = 2 * 1000; /* FC-FS default */ |
464 | lp->r_a_tov = 2 * 2 * 1000; | 504 | lport->r_a_tov = 2 * 2 * 1000; |
465 | lp->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS | | 505 | lport->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS | |
466 | FCP_SPPF_RETRY | FCP_SPPF_CONF_COMPL); | 506 | FCP_SPPF_RETRY | FCP_SPPF_CONF_COMPL); |
467 | lp->does_npiv = 1; | 507 | lport->does_npiv = 1; |
468 | 508 | ||
469 | fc_lport_init_stats(lp); | 509 | fc_lport_init_stats(lport); |
470 | 510 | ||
471 | /* lport fc_lport related configuration */ | 511 | /* lport fc_lport related configuration */ |
472 | fc_lport_config(lp); | 512 | fc_lport_config(lport); |
473 | 513 | ||
474 | /* offload related configuration */ | 514 | /* offload related configuration */ |
475 | lp->crc_offload = 0; | 515 | lport->crc_offload = 0; |
476 | lp->seq_offload = 0; | 516 | lport->seq_offload = 0; |
477 | lp->lro_enabled = 0; | 517 | lport->lro_enabled = 0; |
478 | lp->lro_xid = 0; | 518 | lport->lro_xid = 0; |
479 | lp->lso_max = 0; | 519 | lport->lso_max = 0; |
480 | 520 | ||
481 | return 0; | 521 | return 0; |
482 | } | 522 | } |
483 | 523 | ||
484 | /** | 524 | /** |
485 | * fcoe_queue_timer() - fcoe queue timer | 525 | * fcoe_queue_timer() - The fcoe queue timer |
486 | * @lp: the fc_lport pointer | 526 | * @lport: The local port |
487 | * | 527 | * |
488 | * Calls fcoe_check_wait_queue on timeout | 528 | * Calls fcoe_check_wait_queue on timeout |
489 | * | ||
490 | */ | 529 | */ |
491 | static void fcoe_queue_timer(ulong lp) | 530 | static void fcoe_queue_timer(ulong lport) |
492 | { | 531 | { |
493 | fcoe_check_wait_queue((struct fc_lport *)lp, NULL); | 532 | fcoe_check_wait_queue((struct fc_lport *)lport, NULL); |
494 | } | 533 | } |
495 | 534 | ||
496 | /** | 535 | /** |
497 | * fcoe_netdev_config() - Set up netdev for SW FCoE | 536 | * fcoe_netdev_config() - Set up net devive for SW FCoE |
498 | * @lp : ptr to the fc_lport | 537 | * @lport: The local port that is associated with the net device |
499 | * @netdev : ptr to the associated netdevice struct | 538 | * @netdev: The associated net device |
500 | * | 539 | * |
501 | * Must be called after fcoe_lport_config() as it will use lport mutex | 540 | * Must be called after fcoe_lport_config() as it will use local port mutex |
502 | * | 541 | * |
503 | * Returns : 0 for success | 542 | * Returns: 0 for success |
504 | */ | 543 | */ |
505 | static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) | 544 | static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev) |
506 | { | 545 | { |
507 | u32 mfs; | 546 | u32 mfs; |
508 | u64 wwnn, wwpn; | 547 | u64 wwnn, wwpn; |
@@ -510,7 +549,7 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) | |||
510 | struct fcoe_port *port; | 549 | struct fcoe_port *port; |
511 | 550 | ||
512 | /* Setup lport private data to point to fcoe softc */ | 551 | /* Setup lport private data to point to fcoe softc */ |
513 | port = lport_priv(lp); | 552 | port = lport_priv(lport); |
514 | fcoe = port->fcoe; | 553 | fcoe = port->fcoe; |
515 | 554 | ||
516 | /* | 555 | /* |
@@ -524,91 +563,100 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) | |||
524 | FCOE_NETDEV_DBG(netdev, "Supports FCOE_MTU of %d bytes\n", mfs); | 563 | FCOE_NETDEV_DBG(netdev, "Supports FCOE_MTU of %d bytes\n", mfs); |
525 | } | 564 | } |
526 | mfs -= (sizeof(struct fcoe_hdr) + sizeof(struct fcoe_crc_eof)); | 565 | mfs -= (sizeof(struct fcoe_hdr) + sizeof(struct fcoe_crc_eof)); |
527 | if (fc_set_mfs(lp, mfs)) | 566 | if (fc_set_mfs(lport, mfs)) |
528 | return -EINVAL; | 567 | return -EINVAL; |
529 | 568 | ||
530 | /* offload features support */ | 569 | /* offload features support */ |
531 | if (netdev->features & NETIF_F_SG) | 570 | if (netdev->features & NETIF_F_SG) |
532 | lp->sg_supp = 1; | 571 | lport->sg_supp = 1; |
533 | 572 | ||
534 | if (netdev->features & NETIF_F_FCOE_CRC) { | 573 | if (netdev->features & NETIF_F_FCOE_CRC) { |
535 | lp->crc_offload = 1; | 574 | lport->crc_offload = 1; |
536 | FCOE_NETDEV_DBG(netdev, "Supports FCCRC offload\n"); | 575 | FCOE_NETDEV_DBG(netdev, "Supports FCCRC offload\n"); |
537 | } | 576 | } |
538 | if (netdev->features & NETIF_F_FSO) { | 577 | if (netdev->features & NETIF_F_FSO) { |
539 | lp->seq_offload = 1; | 578 | lport->seq_offload = 1; |
540 | lp->lso_max = netdev->gso_max_size; | 579 | lport->lso_max = netdev->gso_max_size; |
541 | FCOE_NETDEV_DBG(netdev, "Supports LSO for max len 0x%x\n", | 580 | FCOE_NETDEV_DBG(netdev, "Supports LSO for max len 0x%x\n", |
542 | lp->lso_max); | 581 | lport->lso_max); |
543 | } | 582 | } |
544 | if (netdev->fcoe_ddp_xid) { | 583 | if (netdev->fcoe_ddp_xid) { |
545 | lp->lro_enabled = 1; | 584 | lport->lro_enabled = 1; |
546 | lp->lro_xid = netdev->fcoe_ddp_xid; | 585 | lport->lro_xid = netdev->fcoe_ddp_xid; |
547 | FCOE_NETDEV_DBG(netdev, "Supports LRO for max xid 0x%x\n", | 586 | FCOE_NETDEV_DBG(netdev, "Supports LRO for max xid 0x%x\n", |
548 | lp->lro_xid); | 587 | lport->lro_xid); |
549 | } | 588 | } |
550 | skb_queue_head_init(&port->fcoe_pending_queue); | 589 | skb_queue_head_init(&port->fcoe_pending_queue); |
551 | port->fcoe_pending_queue_active = 0; | 590 | port->fcoe_pending_queue_active = 0; |
552 | setup_timer(&port->timer, fcoe_queue_timer, (unsigned long)lp); | 591 | setup_timer(&port->timer, fcoe_queue_timer, (unsigned long)lport); |
553 | 592 | ||
554 | if (!lp->vport) { | 593 | if (!lport->vport) { |
555 | wwnn = fcoe_wwn_from_mac(netdev->dev_addr, 1, 0); | 594 | wwnn = fcoe_wwn_from_mac(netdev->dev_addr, 1, 0); |
556 | fc_set_wwnn(lp, wwnn); | 595 | fc_set_wwnn(lport, wwnn); |
557 | /* XXX - 3rd arg needs to be vlan id */ | 596 | /* XXX - 3rd arg needs to be vlan id */ |
558 | wwpn = fcoe_wwn_from_mac(netdev->dev_addr, 2, 0); | 597 | wwpn = fcoe_wwn_from_mac(netdev->dev_addr, 2, 0); |
559 | fc_set_wwpn(lp, wwpn); | 598 | fc_set_wwpn(lport, wwpn); |
560 | } | 599 | } |
561 | 600 | ||
562 | return 0; | 601 | return 0; |
563 | } | 602 | } |
564 | 603 | ||
565 | /** | 604 | /** |
566 | * fcoe_shost_config() - Sets up fc_lport->host | 605 | * fcoe_shost_config() - Set up the SCSI host associated with a local port |
567 | * @lp : ptr to the fc_lport | 606 | * @lport: The local port |
568 | * @shost : ptr to the associated scsi host | 607 | * @shost: The SCSI host to associate with the local port |
569 | * @dev : device associated to scsi host | 608 | * @dev: The device associated with the SCSI host |
570 | * | 609 | * |
571 | * Must be called after fcoe_lport_config() and fcoe_netdev_config() | 610 | * Must be called after fcoe_lport_config() and fcoe_netdev_config() |
572 | * | 611 | * |
573 | * Returns : 0 for success | 612 | * Returns: 0 for success |
574 | */ | 613 | */ |
575 | static int fcoe_shost_config(struct fc_lport *lp, struct Scsi_Host *shost, | 614 | static int fcoe_shost_config(struct fc_lport *lport, struct Scsi_Host *shost, |
576 | struct device *dev) | 615 | struct device *dev) |
577 | { | 616 | { |
578 | int rc = 0; | 617 | int rc = 0; |
579 | 618 | ||
580 | /* lport scsi host config */ | 619 | /* lport scsi host config */ |
581 | lp->host->max_lun = FCOE_MAX_LUN; | 620 | lport->host->max_lun = FCOE_MAX_LUN; |
582 | lp->host->max_id = FCOE_MAX_FCP_TARGET; | 621 | lport->host->max_id = FCOE_MAX_FCP_TARGET; |
583 | lp->host->max_channel = 0; | 622 | lport->host->max_channel = 0; |
584 | if (lp->vport) | 623 | if (lport->vport) |
585 | lp->host->transportt = fcoe_vport_transport_template; | 624 | lport->host->transportt = fcoe_vport_transport_template; |
586 | else | 625 | else |
587 | lp->host->transportt = fcoe_transport_template; | 626 | lport->host->transportt = fcoe_transport_template; |
588 | 627 | ||
589 | /* add the new host to the SCSI-ml */ | 628 | /* add the new host to the SCSI-ml */ |
590 | rc = scsi_add_host(lp->host, dev); | 629 | rc = scsi_add_host(lport->host, dev); |
591 | if (rc) { | 630 | if (rc) { |
592 | FCOE_NETDEV_DBG(fcoe_netdev(lp), "fcoe_shost_config: " | 631 | FCOE_NETDEV_DBG(fcoe_netdev(lport), "fcoe_shost_config: " |
593 | "error on scsi_add_host\n"); | 632 | "error on scsi_add_host\n"); |
594 | return rc; | 633 | return rc; |
595 | } | 634 | } |
596 | 635 | ||
597 | if (!lp->vport) | 636 | if (!lport->vport) |
598 | fc_host_max_npiv_vports(lp->host) = USHORT_MAX; | 637 | fc_host_max_npiv_vports(lport->host) = USHORT_MAX; |
599 | 638 | ||
600 | snprintf(fc_host_symbolic_name(lp->host), FC_SYMBOLIC_NAME_SIZE, | 639 | snprintf(fc_host_symbolic_name(lport->host), FC_SYMBOLIC_NAME_SIZE, |
601 | "%s v%s over %s", FCOE_NAME, FCOE_VERSION, | 640 | "%s v%s over %s", FCOE_NAME, FCOE_VERSION, |
602 | fcoe_netdev(lp)->name); | 641 | fcoe_netdev(lport)->name); |
603 | 642 | ||
604 | return 0; | 643 | return 0; |
605 | } | 644 | } |
606 | 645 | ||
607 | /* | 646 | /** |
608 | * fcoe_oem_match() - match for read types IO | 647 | * fcoe_oem_match() - The match routine for the offloaded exchange manager |
609 | * @fp: the fc_frame for new IO. | 648 | * @fp: The I/O frame |
610 | * | 649 | * |
611 | * Returns : true for read types IO, otherwise returns false. | 650 | * This routine will be associated with an exchange manager (EM). When |
651 | * the libfc exchange handling code is looking for an EM to use it will | ||
652 | * call this routine and pass it the frame that it wishes to send. This | ||
653 | * routine will return True if the associated EM is to be used and False | ||
654 | * if the echange code should continue looking for an EM. | ||
655 | * | ||
656 | * The offload EM that this routine is associated with will handle any | ||
657 | * packets that are for SCSI read requests. | ||
658 | * | ||
659 | * Returns: True for read types I/O, otherwise returns false. | ||
612 | */ | 660 | */ |
613 | bool fcoe_oem_match(struct fc_frame *fp) | 661 | bool fcoe_oem_match(struct fc_frame *fp) |
614 | { | 662 | { |
@@ -617,14 +665,14 @@ bool fcoe_oem_match(struct fc_frame *fp) | |||
617 | } | 665 | } |
618 | 666 | ||
619 | /** | 667 | /** |
620 | * fcoe_em_config() - allocates em for this lport | 668 | * fcoe_em_config() - Allocate and configure an exchange manager |
621 | * @lp: the fcoe that em is to allocated for | 669 | * @lport: The local port that the new EM will be associated with |
622 | * | 670 | * |
623 | * Returns : 0 on success | 671 | * Returns: 0 on success |
624 | */ | 672 | */ |
625 | static inline int fcoe_em_config(struct fc_lport *lp) | 673 | static inline int fcoe_em_config(struct fc_lport *lport) |
626 | { | 674 | { |
627 | struct fcoe_port *port = lport_priv(lp); | 675 | struct fcoe_port *port = lport_priv(lport); |
628 | struct fcoe_interface *fcoe = port->fcoe; | 676 | struct fcoe_interface *fcoe = port->fcoe; |
629 | struct fcoe_interface *oldfcoe = NULL; | 677 | struct fcoe_interface *oldfcoe = NULL; |
630 | struct net_device *old_real_dev, *cur_real_dev; | 678 | struct net_device *old_real_dev, *cur_real_dev; |
@@ -635,8 +683,9 @@ static inline int fcoe_em_config(struct fc_lport *lp) | |||
635 | * Check if need to allocate an em instance for | 683 | * Check if need to allocate an em instance for |
636 | * offload exchange ids to be shared across all VN_PORTs/lport. | 684 | * offload exchange ids to be shared across all VN_PORTs/lport. |
637 | */ | 685 | */ |
638 | if (!lp->lro_enabled || !lp->lro_xid || (lp->lro_xid >= max_xid)) { | 686 | if (!lport->lro_enabled || !lport->lro_xid || |
639 | lp->lro_xid = 0; | 687 | (lport->lro_xid >= max_xid)) { |
688 | lport->lro_xid = 0; | ||
640 | goto skip_oem; | 689 | goto skip_oem; |
641 | } | 690 | } |
642 | 691 | ||
@@ -662,16 +711,16 @@ static inline int fcoe_em_config(struct fc_lport *lp) | |||
662 | } | 711 | } |
663 | 712 | ||
664 | if (fcoe->oem) { | 713 | if (fcoe->oem) { |
665 | if (!fc_exch_mgr_add(lp, fcoe->oem, fcoe_oem_match)) { | 714 | if (!fc_exch_mgr_add(lport, fcoe->oem, fcoe_oem_match)) { |
666 | printk(KERN_ERR "fcoe_em_config: failed to add " | 715 | printk(KERN_ERR "fcoe_em_config: failed to add " |
667 | "offload em:%p on interface:%s\n", | 716 | "offload em:%p on interface:%s\n", |
668 | fcoe->oem, fcoe->netdev->name); | 717 | fcoe->oem, fcoe->netdev->name); |
669 | return -ENOMEM; | 718 | return -ENOMEM; |
670 | } | 719 | } |
671 | } else { | 720 | } else { |
672 | fcoe->oem = fc_exch_mgr_alloc(lp, FC_CLASS_3, | 721 | fcoe->oem = fc_exch_mgr_alloc(lport, FC_CLASS_3, |
673 | FCOE_MIN_XID, lp->lro_xid, | 722 | FCOE_MIN_XID, lport->lro_xid, |
674 | fcoe_oem_match); | 723 | fcoe_oem_match); |
675 | if (!fcoe->oem) { | 724 | if (!fcoe->oem) { |
676 | printk(KERN_ERR "fcoe_em_config: failed to allocate " | 725 | printk(KERN_ERR "fcoe_em_config: failed to allocate " |
677 | "em for offload exches on interface:%s\n", | 726 | "em for offload exches on interface:%s\n", |
@@ -683,10 +732,10 @@ static inline int fcoe_em_config(struct fc_lport *lp) | |||
683 | /* | 732 | /* |
684 | * Exclude offload EM xid range from next EM xid range. | 733 | * Exclude offload EM xid range from next EM xid range. |
685 | */ | 734 | */ |
686 | min_xid += lp->lro_xid + 1; | 735 | min_xid += lport->lro_xid + 1; |
687 | 736 | ||
688 | skip_oem: | 737 | skip_oem: |
689 | if (!fc_exch_mgr_alloc(lp, FC_CLASS_3, min_xid, max_xid, NULL)) { | 738 | if (!fc_exch_mgr_alloc(lport, FC_CLASS_3, min_xid, max_xid, NULL)) { |
690 | printk(KERN_ERR "fcoe_em_config: failed to " | 739 | printk(KERN_ERR "fcoe_em_config: failed to " |
691 | "allocate em on interface %s\n", fcoe->netdev->name); | 740 | "allocate em on interface %s\n", fcoe->netdev->name); |
692 | return -ENOMEM; | 741 | return -ENOMEM; |
@@ -696,8 +745,8 @@ skip_oem: | |||
696 | } | 745 | } |
697 | 746 | ||
698 | /** | 747 | /** |
699 | * fcoe_if_destroy() - FCoE software HBA tear-down function | 748 | * fcoe_if_destroy() - Tear down a SW FCoE instance |
700 | * @lport: fc_lport to destroy | 749 | * @lport: The local port to be destroyed |
701 | */ | 750 | */ |
702 | static void fcoe_if_destroy(struct fc_lport *lport) | 751 | static void fcoe_if_destroy(struct fc_lport *lport) |
703 | { | 752 | { |
@@ -745,72 +794,62 @@ static void fcoe_if_destroy(struct fc_lport *lport) | |||
745 | scsi_host_put(lport->host); | 794 | scsi_host_put(lport->host); |
746 | } | 795 | } |
747 | 796 | ||
748 | /* | 797 | /** |
749 | * fcoe_ddp_setup - calls LLD's ddp_setup through net_device | 798 | * fcoe_ddp_setup() - Call a LLD's ddp_setup through the net device |
750 | * @lp: the corresponding fc_lport | 799 | * @lport: The local port to setup DDP for |
751 | * @xid: the exchange id for this ddp transfer | 800 | * @xid: The exchange ID for this DDP transfer |
752 | * @sgl: the scatterlist describing this transfer | 801 | * @sgl: The scatterlist describing this transfer |
753 | * @sgc: number of sg items | 802 | * @sgc: The number of sg items |
754 | * | 803 | * |
755 | * Returns : 0 no ddp | 804 | * Returns: 0 if the DDP context was not configured |
756 | */ | 805 | */ |
757 | static int fcoe_ddp_setup(struct fc_lport *lp, u16 xid, | 806 | static int fcoe_ddp_setup(struct fc_lport *lport, u16 xid, |
758 | struct scatterlist *sgl, unsigned int sgc) | 807 | struct scatterlist *sgl, unsigned int sgc) |
759 | { | 808 | { |
760 | struct net_device *n = fcoe_netdev(lp); | 809 | struct net_device *netdev = fcoe_netdev(lport); |
761 | 810 | ||
762 | if (n->netdev_ops->ndo_fcoe_ddp_setup) | 811 | if (netdev->netdev_ops->ndo_fcoe_ddp_setup) |
763 | return n->netdev_ops->ndo_fcoe_ddp_setup(n, xid, sgl, sgc); | 812 | return netdev->netdev_ops->ndo_fcoe_ddp_setup(netdev, |
813 | xid, sgl, | ||
814 | sgc); | ||
764 | 815 | ||
765 | return 0; | 816 | return 0; |
766 | } | 817 | } |
767 | 818 | ||
768 | /* | 819 | /** |
769 | * fcoe_ddp_done - calls LLD's ddp_done through net_device | 820 | * fcoe_ddp_done() - Call a LLD's ddp_done through the net device |
770 | * @lp: the corresponding fc_lport | 821 | * @lport: The local port to complete DDP on |
771 | * @xid: the exchange id for this ddp transfer | 822 | * @xid: The exchange ID for this DDP transfer |
772 | * | 823 | * |
773 | * Returns : the length of data that have been completed by ddp | 824 | * Returns: the length of data that have been completed by DDP |
774 | */ | 825 | */ |
775 | static int fcoe_ddp_done(struct fc_lport *lp, u16 xid) | 826 | static int fcoe_ddp_done(struct fc_lport *lport, u16 xid) |
776 | { | 827 | { |
777 | struct net_device *n = fcoe_netdev(lp); | 828 | struct net_device *netdev = fcoe_netdev(lport); |
778 | 829 | ||
779 | if (n->netdev_ops->ndo_fcoe_ddp_done) | 830 | if (netdev->netdev_ops->ndo_fcoe_ddp_done) |
780 | return n->netdev_ops->ndo_fcoe_ddp_done(n, xid); | 831 | return netdev->netdev_ops->ndo_fcoe_ddp_done(netdev, xid); |
781 | return 0; | 832 | return 0; |
782 | } | 833 | } |
783 | 834 | ||
784 | static struct fc_seq *fcoe_elsct_send(struct fc_lport *lport, | ||
785 | u32 did, struct fc_frame *fp, unsigned int op, | ||
786 | void (*resp)(struct fc_seq *, struct fc_frame *, void *), | ||
787 | void *arg, u32 timeout); | ||
788 | |||
789 | static struct libfc_function_template fcoe_libfc_fcn_templ = { | ||
790 | .frame_send = fcoe_xmit, | ||
791 | .ddp_setup = fcoe_ddp_setup, | ||
792 | .ddp_done = fcoe_ddp_done, | ||
793 | .elsct_send = fcoe_elsct_send, | ||
794 | }; | ||
795 | |||
796 | /** | 835 | /** |
797 | * fcoe_if_create() - this function creates the fcoe port | 836 | * fcoe_if_create() - Create a FCoE instance on an interface |
798 | * @fcoe: fcoe_interface structure to create an fc_lport instance on | 837 | * @fcoe: The FCoE interface to create a local port on |
799 | * @parent: device pointer to be the parent in sysfs for the SCSI host | 838 | * @parent: The device pointer to be the parent in sysfs for the SCSI host |
800 | * @npiv: is this a vport? | 839 | * @npiv: Indicates if the port is a vport or not |
801 | * | 840 | * |
802 | * Creates fc_lport struct and scsi_host for lport, configures lport. | 841 | * Creates a fc_lport instance and a Scsi_Host instance and configure them. |
803 | * | 842 | * |
804 | * Returns : The allocated fc_lport or an error pointer | 843 | * Returns: The allocated fc_lport or an error pointer |
805 | */ | 844 | */ |
806 | static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe, | 845 | static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe, |
807 | struct device *parent, int npiv) | 846 | struct device *parent, int npiv) |
808 | { | 847 | { |
809 | int rc; | 848 | struct net_device *netdev = fcoe->netdev; |
810 | struct fc_lport *lport = NULL; | 849 | struct fc_lport *lport = NULL; |
811 | struct fcoe_port *port; | 850 | struct fcoe_port *port; |
812 | struct Scsi_Host *shost; | 851 | struct Scsi_Host *shost; |
813 | struct net_device *netdev = fcoe->netdev; | 852 | int rc; |
814 | /* | 853 | /* |
815 | * parent is only a vport if npiv is 1, | 854 | * parent is only a vport if npiv is 1, |
816 | * but we'll only use vport in that case so go ahead and set it | 855 | * but we'll only use vport in that case so go ahead and set it |
@@ -837,7 +876,7 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe, | |||
837 | port->fcoe = fcoe; | 876 | port->fcoe = fcoe; |
838 | INIT_WORK(&port->destroy_work, fcoe_destroy_work); | 877 | INIT_WORK(&port->destroy_work, fcoe_destroy_work); |
839 | 878 | ||
840 | /* configure fc_lport, e.g., em */ | 879 | /* configure a fc_lport including the exchange manager */ |
841 | rc = fcoe_lport_config(lport); | 880 | rc = fcoe_lport_config(lport); |
842 | if (rc) { | 881 | if (rc) { |
843 | FCOE_NETDEV_DBG(netdev, "Could not configure lport for the " | 882 | FCOE_NETDEV_DBG(netdev, "Could not configure lport for the " |
@@ -847,7 +886,7 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe, | |||
847 | 886 | ||
848 | if (npiv) { | 887 | if (npiv) { |
849 | FCOE_NETDEV_DBG(netdev, "Setting vport names, 0x%llX 0x%llX\n", | 888 | FCOE_NETDEV_DBG(netdev, "Setting vport names, 0x%llX 0x%llX\n", |
850 | vport->node_name, vport->port_name); | 889 | vport->node_name, vport->port_name); |
851 | fc_set_wwnn(lport, vport->node_name); | 890 | fc_set_wwnn(lport, vport->node_name); |
852 | fc_set_wwpn(lport, vport->port_name); | 891 | fc_set_wwpn(lport, vport->port_name); |
853 | } | 892 | } |
@@ -891,7 +930,7 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe, | |||
891 | rc = fcoe_em_config(lport); | 930 | rc = fcoe_em_config(lport); |
892 | if (rc) { | 931 | if (rc) { |
893 | FCOE_NETDEV_DBG(netdev, "Could not configure the EM " | 932 | FCOE_NETDEV_DBG(netdev, "Could not configure the EM " |
894 | "for the interface\n"); | 933 | "for the interface\n"); |
895 | goto out_lp_destroy; | 934 | goto out_lp_destroy; |
896 | } | 935 | } |
897 | } | 936 | } |
@@ -908,9 +947,11 @@ out: | |||
908 | } | 947 | } |
909 | 948 | ||
910 | /** | 949 | /** |
911 | * fcoe_if_init() - attach to scsi transport | 950 | * fcoe_if_init() - Initialization routine for fcoe.ko |
912 | * | 951 | * |
913 | * Returns : 0 on success | 952 | * Attaches the SW FCoE transport to the FC transport |
953 | * | ||
954 | * Returns: 0 on success | ||
914 | */ | 955 | */ |
915 | static int __init fcoe_if_init(void) | 956 | static int __init fcoe_if_init(void) |
916 | { | 957 | { |
@@ -928,9 +969,11 @@ static int __init fcoe_if_init(void) | |||
928 | } | 969 | } |
929 | 970 | ||
930 | /** | 971 | /** |
931 | * fcoe_if_exit() - detach from scsi transport | 972 | * fcoe_if_exit() - Tear down fcoe.ko |
973 | * | ||
974 | * Detaches the SW FCoE transport from the FC transport | ||
932 | * | 975 | * |
933 | * Returns : 0 on success | 976 | * Returns: 0 on success |
934 | */ | 977 | */ |
935 | int __exit fcoe_if_exit(void) | 978 | int __exit fcoe_if_exit(void) |
936 | { | 979 | { |
@@ -942,8 +985,8 @@ int __exit fcoe_if_exit(void) | |||
942 | } | 985 | } |
943 | 986 | ||
944 | /** | 987 | /** |
945 | * fcoe_percpu_thread_create() - Create a receive thread for an online cpu | 988 | * fcoe_percpu_thread_create() - Create a receive thread for an online CPU |
946 | * @cpu: cpu index for the online cpu | 989 | * @cpu: The CPU index of the CPU to create a receive thread for |
947 | */ | 990 | */ |
948 | static void fcoe_percpu_thread_create(unsigned int cpu) | 991 | static void fcoe_percpu_thread_create(unsigned int cpu) |
949 | { | 992 | { |
@@ -966,8 +1009,8 @@ static void fcoe_percpu_thread_create(unsigned int cpu) | |||
966 | } | 1009 | } |
967 | 1010 | ||
968 | /** | 1011 | /** |
969 | * fcoe_percpu_thread_destroy() - removes the rx thread for the given cpu | 1012 | * fcoe_percpu_thread_destroy() - Remove the receive thread of a CPU |
970 | * @cpu: cpu index the rx thread is to be removed | 1013 | * @cpu: The CPU index of the CPU whose receive thread is to be destroyed |
971 | * | 1014 | * |
972 | * Destroys a per-CPU Rx thread. Any pending skbs are moved to the | 1015 | * Destroys a per-CPU Rx thread. Any pending skbs are moved to the |
973 | * current CPU's Rx thread. If the thread being destroyed is bound to | 1016 | * current CPU's Rx thread. If the thread being destroyed is bound to |
@@ -1015,7 +1058,7 @@ static void fcoe_percpu_thread_destroy(unsigned int cpu) | |||
1015 | } else { | 1058 | } else { |
1016 | /* | 1059 | /* |
1017 | * The targeted CPU is not initialized and cannot accept | 1060 | * The targeted CPU is not initialized and cannot accept |
1018 | * new skbs. Unlock the targeted CPU and drop the skbs | 1061 | * new skbs. Unlock the targeted CPU and drop the skbs |
1019 | * on the CPU that is going offline. | 1062 | * on the CPU that is going offline. |
1020 | */ | 1063 | */ |
1021 | while ((skb = __skb_dequeue(&p->fcoe_rx_list)) != NULL) | 1064 | while ((skb = __skb_dequeue(&p->fcoe_rx_list)) != NULL) |
@@ -1056,12 +1099,12 @@ static void fcoe_percpu_thread_destroy(unsigned int cpu) | |||
1056 | } | 1099 | } |
1057 | 1100 | ||
1058 | /** | 1101 | /** |
1059 | * fcoe_cpu_callback() - fcoe cpu hotplug event callback | 1102 | * fcoe_cpu_callback() - Handler for CPU hotplug events |
1060 | * @nfb: callback data block | 1103 | * @nfb: The callback data block |
1061 | * @action: event triggering the callback | 1104 | * @action: The event triggering the callback |
1062 | * @hcpu: index for the cpu of this event | 1105 | * @hcpu: The index of the CPU that the event is for |
1063 | * | 1106 | * |
1064 | * This creates or destroys per cpu data for fcoe | 1107 | * This creates or destroys per-CPU data for fcoe |
1065 | * | 1108 | * |
1066 | * Returns NOTIFY_OK always. | 1109 | * Returns NOTIFY_OK always. |
1067 | */ | 1110 | */ |
@@ -1087,25 +1130,22 @@ static int fcoe_cpu_callback(struct notifier_block *nfb, | |||
1087 | return NOTIFY_OK; | 1130 | return NOTIFY_OK; |
1088 | } | 1131 | } |
1089 | 1132 | ||
1090 | static struct notifier_block fcoe_cpu_notifier = { | ||
1091 | .notifier_call = fcoe_cpu_callback, | ||
1092 | }; | ||
1093 | |||
1094 | /** | 1133 | /** |
1095 | * fcoe_rcv() - this is the fcoe receive function called by NET_RX_SOFTIRQ | 1134 | * fcoe_rcv() - Receive packets from a net device |
1096 | * @skb: the receive skb | 1135 | * @skb: The received packet |
1097 | * @dev: associated net device | 1136 | * @netdev: The net device that the packet was received on |
1098 | * @ptype: context | 1137 | * @ptype: The packet type context |
1099 | * @olddev: last device | 1138 | * @olddev: The last device net device |
1100 | * | 1139 | * |
1101 | * this function will receive the packet and build fc frame and pass it up | 1140 | * This routine is called by NET_RX_SOFTIRQ. It receives a packet, builds a |
1141 | * FC frame and passes the frame to libfc. | ||
1102 | * | 1142 | * |
1103 | * Returns: 0 for success | 1143 | * Returns: 0 for success |
1104 | */ | 1144 | */ |
1105 | int fcoe_rcv(struct sk_buff *skb, struct net_device *dev, | 1145 | int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, |
1106 | struct packet_type *ptype, struct net_device *olddev) | 1146 | struct packet_type *ptype, struct net_device *olddev) |
1107 | { | 1147 | { |
1108 | struct fc_lport *lp; | 1148 | struct fc_lport *lport; |
1109 | struct fcoe_rcv_info *fr; | 1149 | struct fcoe_rcv_info *fr; |
1110 | struct fcoe_interface *fcoe; | 1150 | struct fcoe_interface *fcoe; |
1111 | struct fc_frame_header *fh; | 1151 | struct fc_frame_header *fh; |
@@ -1113,15 +1153,15 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev, | |||
1113 | unsigned int cpu; | 1153 | unsigned int cpu; |
1114 | 1154 | ||
1115 | fcoe = container_of(ptype, struct fcoe_interface, fcoe_packet_type); | 1155 | fcoe = container_of(ptype, struct fcoe_interface, fcoe_packet_type); |
1116 | lp = fcoe->ctlr.lp; | 1156 | lport = fcoe->ctlr.lp; |
1117 | if (unlikely(lp == NULL)) { | 1157 | if (unlikely(!lport)) { |
1118 | FCOE_NETDEV_DBG(dev, "Cannot find hba structure"); | 1158 | FCOE_NETDEV_DBG(netdev, "Cannot find hba structure"); |
1119 | goto err2; | 1159 | goto err2; |
1120 | } | 1160 | } |
1121 | if (!lp->link_up) | 1161 | if (!lport->link_up) |
1122 | goto err2; | 1162 | goto err2; |
1123 | 1163 | ||
1124 | FCOE_NETDEV_DBG(dev, "skb_info: len:%d data_len:%d head:%p " | 1164 | FCOE_NETDEV_DBG(netdev, "skb_info: len:%d data_len:%d head:%p " |
1125 | "data:%p tail:%p end:%p sum:%d dev:%s", | 1165 | "data:%p tail:%p end:%p sum:%d dev:%s", |
1126 | skb->len, skb->data_len, skb->head, skb->data, | 1166 | skb->len, skb->data_len, skb->head, skb->data, |
1127 | skb_tail_pointer(skb), skb_end_pointer(skb), | 1167 | skb_tail_pointer(skb), skb_end_pointer(skb), |
@@ -1129,7 +1169,7 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev, | |||
1129 | 1169 | ||
1130 | /* check for FCOE packet type */ | 1170 | /* check for FCOE packet type */ |
1131 | if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) { | 1171 | if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) { |
1132 | FCOE_NETDEV_DBG(dev, "Wrong FC type frame"); | 1172 | FCOE_NETDEV_DBG(netdev, "Wrong FC type frame"); |
1133 | goto err; | 1173 | goto err; |
1134 | } | 1174 | } |
1135 | 1175 | ||
@@ -1138,14 +1178,14 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev, | |||
1138 | * and FC headers are pulled into the linear data area. | 1178 | * and FC headers are pulled into the linear data area. |
1139 | */ | 1179 | */ |
1140 | if (unlikely((skb->len < FCOE_MIN_FRAME) || | 1180 | if (unlikely((skb->len < FCOE_MIN_FRAME) || |
1141 | !pskb_may_pull(skb, FCOE_HEADER_LEN))) | 1181 | !pskb_may_pull(skb, FCOE_HEADER_LEN))) |
1142 | goto err; | 1182 | goto err; |
1143 | 1183 | ||
1144 | skb_set_transport_header(skb, sizeof(struct fcoe_hdr)); | 1184 | skb_set_transport_header(skb, sizeof(struct fcoe_hdr)); |
1145 | fh = (struct fc_frame_header *) skb_transport_header(skb); | 1185 | fh = (struct fc_frame_header *) skb_transport_header(skb); |
1146 | 1186 | ||
1147 | fr = fcoe_dev_from_skb(skb); | 1187 | fr = fcoe_dev_from_skb(skb); |
1148 | fr->fr_dev = lp; | 1188 | fr->fr_dev = lport; |
1149 | fr->ptype = ptype; | 1189 | fr->ptype = ptype; |
1150 | 1190 | ||
1151 | /* | 1191 | /* |
@@ -1167,7 +1207,7 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev, | |||
1167 | * the first CPU now. For non-SMP systems this | 1207 | * the first CPU now. For non-SMP systems this |
1168 | * will check the same CPU twice. | 1208 | * will check the same CPU twice. |
1169 | */ | 1209 | */ |
1170 | FCOE_NETDEV_DBG(dev, "CPU is online, but no receive thread " | 1210 | FCOE_NETDEV_DBG(netdev, "CPU is online, but no receive thread " |
1171 | "ready for incoming skb- using first online " | 1211 | "ready for incoming skb- using first online " |
1172 | "CPU.\n"); | 1212 | "CPU.\n"); |
1173 | 1213 | ||
@@ -1194,7 +1234,7 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev, | |||
1194 | 1234 | ||
1195 | return 0; | 1235 | return 0; |
1196 | err: | 1236 | err: |
1197 | fc_lport_get_stats(lp)->ErrorFrames++; | 1237 | fc_lport_get_stats(lport)->ErrorFrames++; |
1198 | 1238 | ||
1199 | err2: | 1239 | err2: |
1200 | kfree_skb(skb); | 1240 | kfree_skb(skb); |
@@ -1202,8 +1242,11 @@ err2: | |||
1202 | } | 1242 | } |
1203 | 1243 | ||
1204 | /** | 1244 | /** |
1205 | * fcoe_start_io() - pass to netdev to start xmit for fcoe | 1245 | * fcoe_start_io() - Start FCoE I/O |
1206 | * @skb: the skb to be xmitted | 1246 | * @skb: The packet to be transmitted |
1247 | * | ||
1248 | * This routine is called from the net device to start transmitting | ||
1249 | * FCoE packets. | ||
1207 | * | 1250 | * |
1208 | * Returns: 0 for success | 1251 | * Returns: 0 for success |
1209 | */ | 1252 | */ |
@@ -1220,9 +1263,15 @@ static inline int fcoe_start_io(struct sk_buff *skb) | |||
1220 | } | 1263 | } |
1221 | 1264 | ||
1222 | /** | 1265 | /** |
1223 | * fcoe_get_paged_crc_eof() - in case we need to alloc a page for crc_eof | 1266 | * fcoe_get_paged_crc_eof() - Allocate a page to be used for the trailer CRC |
1224 | * @skb: the skb to be xmitted | 1267 | * @skb: The packet to be transmitted |
1225 | * @tlen: total len | 1268 | * @tlen: The total length of the trailer |
1269 | * | ||
1270 | * This routine allocates a page for frame trailers. The page is re-used if | ||
1271 | * there is enough room left on it for the current trailer. If there isn't | ||
1272 | * enough buffer left a new page is allocated for the trailer. Reference to | ||
1273 | * the page from this function as well as the skbs using the page fragments | ||
1274 | * ensure that the page is freed at the appropriate time. | ||
1226 | * | 1275 | * |
1227 | * Returns: 0 for success | 1276 | * Returns: 0 for success |
1228 | */ | 1277 | */ |
@@ -1261,11 +1310,12 @@ static int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen) | |||
1261 | } | 1310 | } |
1262 | 1311 | ||
1263 | /** | 1312 | /** |
1264 | * fcoe_fc_crc() - calculates FC CRC in this fcoe skb | 1313 | * fcoe_fc_crc() - Calculates the CRC for a given frame |
1265 | * @fp: the fc_frame containing data to be checksummed | 1314 | * @fp: The frame to be checksumed |
1266 | * | 1315 | * |
1267 | * This uses crc32() to calculate the crc for port frame | 1316 | * This uses crc32() routine to calculate the CRC for a frame |
1268 | * Return : 32 bit crc | 1317 | * |
1318 | * Return: The 32 bit CRC value | ||
1269 | */ | 1319 | */ |
1270 | u32 fcoe_fc_crc(struct fc_frame *fp) | 1320 | u32 fcoe_fc_crc(struct fc_frame *fp) |
1271 | { | 1321 | { |
@@ -1296,13 +1346,13 @@ u32 fcoe_fc_crc(struct fc_frame *fp) | |||
1296 | } | 1346 | } |
1297 | 1347 | ||
1298 | /** | 1348 | /** |
1299 | * fcoe_xmit() - FCoE frame transmit function | 1349 | * fcoe_xmit() - Transmit a FCoE frame |
1300 | * @lp: the associated local fcoe | 1350 | * @lport: The local port that the frame is to be transmitted for |
1301 | * @fp: the fc_frame to be transmitted | 1351 | * @fp: The frame to be transmitted |
1302 | * | 1352 | * |
1303 | * Return : 0 for success | 1353 | * Return: 0 for success |
1304 | */ | 1354 | */ |
1305 | int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) | 1355 | int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) |
1306 | { | 1356 | { |
1307 | int wlen; | 1357 | int wlen; |
1308 | u32 crc; | 1358 | u32 crc; |
@@ -1314,7 +1364,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) | |||
1314 | unsigned int hlen; /* header length implies the version */ | 1364 | unsigned int hlen; /* header length implies the version */ |
1315 | unsigned int tlen; /* trailer length */ | 1365 | unsigned int tlen; /* trailer length */ |
1316 | unsigned int elen; /* eth header, may include vlan */ | 1366 | unsigned int elen; /* eth header, may include vlan */ |
1317 | struct fcoe_port *port = lport_priv(lp); | 1367 | struct fcoe_port *port = lport_priv(lport); |
1318 | struct fcoe_interface *fcoe = port->fcoe; | 1368 | struct fcoe_interface *fcoe = port->fcoe; |
1319 | u8 sof, eof; | 1369 | u8 sof, eof; |
1320 | struct fcoe_hdr *hp; | 1370 | struct fcoe_hdr *hp; |
@@ -1325,13 +1375,13 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) | |||
1325 | skb = fp_skb(fp); | 1375 | skb = fp_skb(fp); |
1326 | wlen = skb->len / FCOE_WORD_TO_BYTE; | 1376 | wlen = skb->len / FCOE_WORD_TO_BYTE; |
1327 | 1377 | ||
1328 | if (!lp->link_up) { | 1378 | if (!lport->link_up) { |
1329 | kfree_skb(skb); | 1379 | kfree_skb(skb); |
1330 | return 0; | 1380 | return 0; |
1331 | } | 1381 | } |
1332 | 1382 | ||
1333 | if (unlikely(fh->fh_r_ctl == FC_RCTL_ELS_REQ) && | 1383 | if (unlikely(fh->fh_r_ctl == FC_RCTL_ELS_REQ) && |
1334 | fcoe_ctlr_els_send(&fcoe->ctlr, lp, skb)) | 1384 | fcoe_ctlr_els_send(&fcoe->ctlr, lport, skb)) |
1335 | return 0; | 1385 | return 0; |
1336 | 1386 | ||
1337 | sof = fr_sof(fp); | 1387 | sof = fr_sof(fp); |
@@ -1343,7 +1393,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) | |||
1343 | wlen = (skb->len - tlen + sizeof(crc)) / FCOE_WORD_TO_BYTE; | 1393 | wlen = (skb->len - tlen + sizeof(crc)) / FCOE_WORD_TO_BYTE; |
1344 | 1394 | ||
1345 | /* crc offload */ | 1395 | /* crc offload */ |
1346 | if (likely(lp->crc_offload)) { | 1396 | if (likely(lport->crc_offload)) { |
1347 | skb->ip_summed = CHECKSUM_PARTIAL; | 1397 | skb->ip_summed = CHECKSUM_PARTIAL; |
1348 | skb->csum_start = skb_headroom(skb); | 1398 | skb->csum_start = skb_headroom(skb); |
1349 | skb->csum_offset = skb->len; | 1399 | skb->csum_offset = skb->len; |
@@ -1405,7 +1455,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) | |||
1405 | hp->fcoe_sof = sof; | 1455 | hp->fcoe_sof = sof; |
1406 | 1456 | ||
1407 | /* fcoe lso, mss is in max_payload which is non-zero for FCP data */ | 1457 | /* fcoe lso, mss is in max_payload which is non-zero for FCP data */ |
1408 | if (lp->seq_offload && fr_max_payload(fp)) { | 1458 | if (lport->seq_offload && fr_max_payload(fp)) { |
1409 | skb_shinfo(skb)->gso_type = SKB_GSO_FCOE; | 1459 | skb_shinfo(skb)->gso_type = SKB_GSO_FCOE; |
1410 | skb_shinfo(skb)->gso_size = fr_max_payload(fp); | 1460 | skb_shinfo(skb)->gso_size = fr_max_payload(fp); |
1411 | } else { | 1461 | } else { |
@@ -1413,23 +1463,23 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) | |||
1413 | skb_shinfo(skb)->gso_size = 0; | 1463 | skb_shinfo(skb)->gso_size = 0; |
1414 | } | 1464 | } |
1415 | /* update tx stats: regardless if LLD fails */ | 1465 | /* update tx stats: regardless if LLD fails */ |
1416 | stats = fc_lport_get_stats(lp); | 1466 | stats = fc_lport_get_stats(lport); |
1417 | stats->TxFrames++; | 1467 | stats->TxFrames++; |
1418 | stats->TxWords += wlen; | 1468 | stats->TxWords += wlen; |
1419 | 1469 | ||
1420 | /* send down to lld */ | 1470 | /* send down to lld */ |
1421 | fr_dev(fp) = lp; | 1471 | fr_dev(fp) = lport; |
1422 | if (port->fcoe_pending_queue.qlen) | 1472 | if (port->fcoe_pending_queue.qlen) |
1423 | fcoe_check_wait_queue(lp, skb); | 1473 | fcoe_check_wait_queue(lport, skb); |
1424 | else if (fcoe_start_io(skb)) | 1474 | else if (fcoe_start_io(skb)) |
1425 | fcoe_check_wait_queue(lp, skb); | 1475 | fcoe_check_wait_queue(lport, skb); |
1426 | 1476 | ||
1427 | return 0; | 1477 | return 0; |
1428 | } | 1478 | } |
1429 | 1479 | ||
1430 | /** | 1480 | /** |
1431 | * fcoe_percpu_flush_done() - Indicate percpu queue flush completion. | 1481 | * fcoe_percpu_flush_done() - Indicate per-CPU queue flush completion |
1432 | * @skb: the skb being completed. | 1482 | * @skb: The completed skb (argument required by destructor) |
1433 | */ | 1483 | */ |
1434 | static void fcoe_percpu_flush_done(struct sk_buff *skb) | 1484 | static void fcoe_percpu_flush_done(struct sk_buff *skb) |
1435 | { | 1485 | { |
@@ -1437,8 +1487,8 @@ static void fcoe_percpu_flush_done(struct sk_buff *skb) | |||
1437 | } | 1487 | } |
1438 | 1488 | ||
1439 | /** | 1489 | /** |
1440 | * fcoe_percpu_receive_thread() - recv thread per cpu | 1490 | * fcoe_percpu_receive_thread() - The per-CPU packet receive thread |
1441 | * @arg: ptr to the fcoe per cpu struct | 1491 | * @arg: The per-CPU context |
1442 | * | 1492 | * |
1443 | * Return: 0 for success | 1493 | * Return: 0 for success |
1444 | */ | 1494 | */ |
@@ -1446,7 +1496,7 @@ int fcoe_percpu_receive_thread(void *arg) | |||
1446 | { | 1496 | { |
1447 | struct fcoe_percpu_s *p = arg; | 1497 | struct fcoe_percpu_s *p = arg; |
1448 | u32 fr_len; | 1498 | u32 fr_len; |
1449 | struct fc_lport *lp; | 1499 | struct fc_lport *lport; |
1450 | struct fcoe_rcv_info *fr; | 1500 | struct fcoe_rcv_info *fr; |
1451 | struct fcoe_dev_stats *stats; | 1501 | struct fcoe_dev_stats *stats; |
1452 | struct fc_frame_header *fh; | 1502 | struct fc_frame_header *fh; |
@@ -1473,8 +1523,8 @@ int fcoe_percpu_receive_thread(void *arg) | |||
1473 | } | 1523 | } |
1474 | spin_unlock_bh(&p->fcoe_rx_list.lock); | 1524 | spin_unlock_bh(&p->fcoe_rx_list.lock); |
1475 | fr = fcoe_dev_from_skb(skb); | 1525 | fr = fcoe_dev_from_skb(skb); |
1476 | lp = fr->fr_dev; | 1526 | lport = fr->fr_dev; |
1477 | if (unlikely(lp == NULL)) { | 1527 | if (unlikely(!lport)) { |
1478 | if (skb->destructor != fcoe_percpu_flush_done) | 1528 | if (skb->destructor != fcoe_percpu_flush_done) |
1479 | FCOE_NETDEV_DBG(skb->dev, "NULL lport in skb"); | 1529 | FCOE_NETDEV_DBG(skb->dev, "NULL lport in skb"); |
1480 | kfree_skb(skb); | 1530 | kfree_skb(skb); |
@@ -1491,7 +1541,7 @@ int fcoe_percpu_receive_thread(void *arg) | |||
1491 | /* | 1541 | /* |
1492 | * Save source MAC address before discarding header. | 1542 | * Save source MAC address before discarding header. |
1493 | */ | 1543 | */ |
1494 | port = lport_priv(lp); | 1544 | port = lport_priv(lport); |
1495 | if (skb_is_nonlinear(skb)) | 1545 | if (skb_is_nonlinear(skb)) |
1496 | skb_linearize(skb); /* not ideal */ | 1546 | skb_linearize(skb); /* not ideal */ |
1497 | mac = eth_hdr(skb)->h_source; | 1547 | mac = eth_hdr(skb)->h_source; |
@@ -1503,7 +1553,7 @@ int fcoe_percpu_receive_thread(void *arg) | |||
1503 | hp = (struct fcoe_hdr *) skb_network_header(skb); | 1553 | hp = (struct fcoe_hdr *) skb_network_header(skb); |
1504 | fh = (struct fc_frame_header *) skb_transport_header(skb); | 1554 | fh = (struct fc_frame_header *) skb_transport_header(skb); |
1505 | 1555 | ||
1506 | stats = fc_lport_get_stats(lp); | 1556 | stats = fc_lport_get_stats(lport); |
1507 | if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) { | 1557 | if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) { |
1508 | if (stats->ErrorFrames < 5) | 1558 | if (stats->ErrorFrames < 5) |
1509 | printk(KERN_WARNING "fcoe: FCoE version " | 1559 | printk(KERN_WARNING "fcoe: FCoE version " |
@@ -1525,7 +1575,7 @@ int fcoe_percpu_receive_thread(void *arg) | |||
1525 | 1575 | ||
1526 | fp = (struct fc_frame *)skb; | 1576 | fp = (struct fc_frame *)skb; |
1527 | fc_frame_init(fp); | 1577 | fc_frame_init(fp); |
1528 | fr_dev(fp) = lp; | 1578 | fr_dev(fp) = lport; |
1529 | fr_sof(fp) = hp->fcoe_sof; | 1579 | fr_sof(fp) = hp->fcoe_sof; |
1530 | 1580 | ||
1531 | /* Copy out the CRC and EOF trailer for access */ | 1581 | /* Copy out the CRC and EOF trailer for access */ |
@@ -1545,7 +1595,8 @@ int fcoe_percpu_receive_thread(void *arg) | |||
1545 | * it's solicited data, in which case, the FCP layer would | 1595 | * it's solicited data, in which case, the FCP layer would |
1546 | * check it during the copy. | 1596 | * check it during the copy. |
1547 | */ | 1597 | */ |
1548 | if (lp->crc_offload && skb->ip_summed == CHECKSUM_UNNECESSARY) | 1598 | if (lport->crc_offload && |
1599 | skb->ip_summed == CHECKSUM_UNNECESSARY) | ||
1549 | fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED; | 1600 | fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED; |
1550 | else | 1601 | else |
1551 | fr_flags(fp) |= FCPHF_CRC_UNCHECKED; | 1602 | fr_flags(fp) |= FCPHF_CRC_UNCHECKED; |
@@ -1553,7 +1604,7 @@ int fcoe_percpu_receive_thread(void *arg) | |||
1553 | fh = fc_frame_header_get(fp); | 1604 | fh = fc_frame_header_get(fp); |
1554 | if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA && | 1605 | if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA && |
1555 | fh->fh_type == FC_TYPE_FCP) { | 1606 | fh->fh_type == FC_TYPE_FCP) { |
1556 | fc_exch_recv(lp, fp); | 1607 | fc_exch_recv(lport, fp); |
1557 | continue; | 1608 | continue; |
1558 | } | 1609 | } |
1559 | if (fr_flags(fp) & FCPHF_CRC_UNCHECKED) { | 1610 | if (fr_flags(fp) & FCPHF_CRC_UNCHECKED) { |
@@ -1569,27 +1620,27 @@ int fcoe_percpu_receive_thread(void *arg) | |||
1569 | } | 1620 | } |
1570 | fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED; | 1621 | fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED; |
1571 | } | 1622 | } |
1572 | fc_exch_recv(lp, fp); | 1623 | fc_exch_recv(lport, fp); |
1573 | } | 1624 | } |
1574 | return 0; | 1625 | return 0; |
1575 | } | 1626 | } |
1576 | 1627 | ||
1577 | /** | 1628 | /** |
1578 | * fcoe_check_wait_queue() - attempt to clear the transmit backlog | 1629 | * fcoe_check_wait_queue() - Attempt to clear the transmit backlog |
1579 | * @lp: the fc_lport | 1630 | * @lport: The local port whose backlog is to be cleared |
1580 | * | 1631 | * |
1581 | * This empties the wait_queue, dequeue the head of the wait_queue queue | 1632 | * This empties the wait_queue, dequeues the head of the wait_queue queue |
1582 | * and calls fcoe_start_io() for each packet, if all skb have been | 1633 | * and calls fcoe_start_io() for each packet. If all skb have been |
1583 | * transmitted, return qlen or -1 if a error occurs, then restore | 1634 | * transmitted it returns the qlen. If an error occurs it restores |
1584 | * wait_queue and try again later. | 1635 | * wait_queue (to try again later) and returns -1. |
1585 | * | 1636 | * |
1586 | * The wait_queue is used when the skb transmit fails. skb will go | 1637 | * The wait_queue is used when the skb transmit fails. The failed skb |
1587 | * in the wait_queue which will be emptied by the timer function or | 1638 | * will go in the wait_queue which will be emptied by the timer function or |
1588 | * by the next skb transmit. | 1639 | * by the next skb transmit. |
1589 | */ | 1640 | */ |
1590 | static void fcoe_check_wait_queue(struct fc_lport *lp, struct sk_buff *skb) | 1641 | static void fcoe_check_wait_queue(struct fc_lport *lport, struct sk_buff *skb) |
1591 | { | 1642 | { |
1592 | struct fcoe_port *port = lport_priv(lp); | 1643 | struct fcoe_port *port = lport_priv(lport); |
1593 | int rc; | 1644 | int rc; |
1594 | 1645 | ||
1595 | spin_lock_bh(&port->fcoe_pending_queue.lock); | 1646 | spin_lock_bh(&port->fcoe_pending_queue.lock); |
@@ -1621,19 +1672,19 @@ static void fcoe_check_wait_queue(struct fc_lport *lp, struct sk_buff *skb) | |||
1621 | } | 1672 | } |
1622 | 1673 | ||
1623 | if (port->fcoe_pending_queue.qlen < FCOE_LOW_QUEUE_DEPTH) | 1674 | if (port->fcoe_pending_queue.qlen < FCOE_LOW_QUEUE_DEPTH) |
1624 | lp->qfull = 0; | 1675 | lport->qfull = 0; |
1625 | if (port->fcoe_pending_queue.qlen && !timer_pending(&port->timer)) | 1676 | if (port->fcoe_pending_queue.qlen && !timer_pending(&port->timer)) |
1626 | mod_timer(&port->timer, jiffies + 2); | 1677 | mod_timer(&port->timer, jiffies + 2); |
1627 | port->fcoe_pending_queue_active = 0; | 1678 | port->fcoe_pending_queue_active = 0; |
1628 | out: | 1679 | out: |
1629 | if (port->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH) | 1680 | if (port->fcoe_pending_queue.qlen > FCOE_MAX_QUEUE_DEPTH) |
1630 | lp->qfull = 1; | 1681 | lport->qfull = 1; |
1631 | spin_unlock_bh(&port->fcoe_pending_queue.lock); | 1682 | spin_unlock_bh(&port->fcoe_pending_queue.lock); |
1632 | return; | 1683 | return; |
1633 | } | 1684 | } |
1634 | 1685 | ||
1635 | /** | 1686 | /** |
1636 | * fcoe_dev_setup() - setup link change notification interface | 1687 | * fcoe_dev_setup() - Setup the link change notification interface |
1637 | */ | 1688 | */ |
1638 | static void fcoe_dev_setup(void) | 1689 | static void fcoe_dev_setup(void) |
1639 | { | 1690 | { |
@@ -1641,7 +1692,7 @@ static void fcoe_dev_setup(void) | |||
1641 | } | 1692 | } |
1642 | 1693 | ||
1643 | /** | 1694 | /** |
1644 | * fcoe_dev_cleanup() - cleanup link change notification interface | 1695 | * fcoe_dev_cleanup() - Cleanup the link change notification interface |
1645 | */ | 1696 | */ |
1646 | static void fcoe_dev_cleanup(void) | 1697 | static void fcoe_dev_cleanup(void) |
1647 | { | 1698 | { |
@@ -1649,19 +1700,19 @@ static void fcoe_dev_cleanup(void) | |||
1649 | } | 1700 | } |
1650 | 1701 | ||
1651 | /** | 1702 | /** |
1652 | * fcoe_device_notification() - netdev event notification callback | 1703 | * fcoe_device_notification() - Handler for net device events |
1653 | * @notifier: context of the notification | 1704 | * @notifier: The context of the notification |
1654 | * @event: type of event | 1705 | * @event: The type of event |
1655 | * @ptr: fixed array for output parsed ifname | 1706 | * @ptr: The net device that the event was on |
1656 | * | 1707 | * |
1657 | * This function is called by the ethernet driver in case of link change event | 1708 | * This function is called by the Ethernet driver in case of link change event. |
1658 | * | 1709 | * |
1659 | * Returns: 0 for success | 1710 | * Returns: 0 for success |
1660 | */ | 1711 | */ |
1661 | static int fcoe_device_notification(struct notifier_block *notifier, | 1712 | static int fcoe_device_notification(struct notifier_block *notifier, |
1662 | ulong event, void *ptr) | 1713 | ulong event, void *ptr) |
1663 | { | 1714 | { |
1664 | struct fc_lport *lp = NULL; | 1715 | struct fc_lport *lport = NULL; |
1665 | struct net_device *netdev = ptr; | 1716 | struct net_device *netdev = ptr; |
1666 | struct fcoe_interface *fcoe; | 1717 | struct fcoe_interface *fcoe; |
1667 | struct fcoe_port *port; | 1718 | struct fcoe_port *port; |
@@ -1672,11 +1723,11 @@ static int fcoe_device_notification(struct notifier_block *notifier, | |||
1672 | 1723 | ||
1673 | list_for_each_entry(fcoe, &fcoe_hostlist, list) { | 1724 | list_for_each_entry(fcoe, &fcoe_hostlist, list) { |
1674 | if (fcoe->netdev == netdev) { | 1725 | if (fcoe->netdev == netdev) { |
1675 | lp = fcoe->ctlr.lp; | 1726 | lport = fcoe->ctlr.lp; |
1676 | break; | 1727 | break; |
1677 | } | 1728 | } |
1678 | } | 1729 | } |
1679 | if (lp == NULL) { | 1730 | if (!lport) { |
1680 | rc = NOTIFY_DONE; | 1731 | rc = NOTIFY_DONE; |
1681 | goto out; | 1732 | goto out; |
1682 | } | 1733 | } |
@@ -1695,7 +1746,7 @@ static int fcoe_device_notification(struct notifier_block *notifier, | |||
1695 | mfs = netdev->mtu - (sizeof(struct fcoe_hdr) + | 1746 | mfs = netdev->mtu - (sizeof(struct fcoe_hdr) + |
1696 | sizeof(struct fcoe_crc_eof)); | 1747 | sizeof(struct fcoe_crc_eof)); |
1697 | if (mfs >= FC_MIN_MAX_FRAME) | 1748 | if (mfs >= FC_MIN_MAX_FRAME) |
1698 | fc_set_mfs(lp, mfs); | 1749 | fc_set_mfs(lport, mfs); |
1699 | break; | 1750 | break; |
1700 | case NETDEV_REGISTER: | 1751 | case NETDEV_REGISTER: |
1701 | break; | 1752 | break; |
@@ -1710,22 +1761,22 @@ static int fcoe_device_notification(struct notifier_block *notifier, | |||
1710 | FCOE_NETDEV_DBG(netdev, "Unknown event %ld " | 1761 | FCOE_NETDEV_DBG(netdev, "Unknown event %ld " |
1711 | "from netdev netlink\n", event); | 1762 | "from netdev netlink\n", event); |
1712 | } | 1763 | } |
1713 | if (link_possible && !fcoe_link_ok(lp)) | 1764 | if (link_possible && !fcoe_link_ok(lport)) |
1714 | fcoe_ctlr_link_up(&fcoe->ctlr); | 1765 | fcoe_ctlr_link_up(&fcoe->ctlr); |
1715 | else if (fcoe_ctlr_link_down(&fcoe->ctlr)) { | 1766 | else if (fcoe_ctlr_link_down(&fcoe->ctlr)) { |
1716 | stats = fc_lport_get_stats(lp); | 1767 | stats = fc_lport_get_stats(lport); |
1717 | stats->LinkFailureCount++; | 1768 | stats->LinkFailureCount++; |
1718 | fcoe_clean_pending_queue(lp); | 1769 | fcoe_clean_pending_queue(lport); |
1719 | } | 1770 | } |
1720 | out: | 1771 | out: |
1721 | return rc; | 1772 | return rc; |
1722 | } | 1773 | } |
1723 | 1774 | ||
1724 | /** | 1775 | /** |
1725 | * fcoe_if_to_netdev() - parse a name buffer to get netdev | 1776 | * fcoe_if_to_netdev() - Parse a name buffer to get a net device |
1726 | * @buffer: incoming buffer to be copied | 1777 | * @buffer: The name of the net device |
1727 | * | 1778 | * |
1728 | * Returns: NULL or ptr to net_device | 1779 | * Returns: NULL or a ptr to net_device |
1729 | */ | 1780 | */ |
1730 | static struct net_device *fcoe_if_to_netdev(const char *buffer) | 1781 | static struct net_device *fcoe_if_to_netdev(const char *buffer) |
1731 | { | 1782 | { |
@@ -1743,9 +1794,11 @@ static struct net_device *fcoe_if_to_netdev(const char *buffer) | |||
1743 | } | 1794 | } |
1744 | 1795 | ||
1745 | /** | 1796 | /** |
1746 | * fcoe_destroy() - handles the destroy from sysfs | 1797 | * fcoe_destroy() - Destroy a FCoE interface |
1747 | * @buffer: expected to be an eth if name | 1798 | * @buffer: The name of the Ethernet interface to be destroyed |
1748 | * @kp: associated kernel param | 1799 | * @kp: The associated kernel parameter |
1800 | * | ||
1801 | * Called from sysfs. | ||
1749 | * | 1802 | * |
1750 | * Returns: 0 for success | 1803 | * Returns: 0 for success |
1751 | */ | 1804 | */ |
@@ -1792,6 +1845,10 @@ out_nodev: | |||
1792 | return rc; | 1845 | return rc; |
1793 | } | 1846 | } |
1794 | 1847 | ||
1848 | /** | ||
1849 | * fcoe_destroy_work() - Destroy a FCoE port in a deferred work context | ||
1850 | * @work: Handle to the FCoE port to be destroyed | ||
1851 | */ | ||
1795 | static void fcoe_destroy_work(struct work_struct *work) | 1852 | static void fcoe_destroy_work(struct work_struct *work) |
1796 | { | 1853 | { |
1797 | struct fcoe_port *port; | 1854 | struct fcoe_port *port; |
@@ -1803,9 +1860,11 @@ static void fcoe_destroy_work(struct work_struct *work) | |||
1803 | } | 1860 | } |
1804 | 1861 | ||
1805 | /** | 1862 | /** |
1806 | * fcoe_create() - Handles the create call from sysfs | 1863 | * fcoe_create() - Create a fcoe interface |
1807 | * @buffer: expected to be an eth if name | 1864 | * @buffer: The name of the Ethernet interface to create on |
1808 | * @kp: associated kernel param | 1865 | * @kp: The associated kernel param |
1866 | * | ||
1867 | * Called from sysfs. | ||
1809 | * | 1868 | * |
1810 | * Returns: 0 for success | 1869 | * Returns: 0 for success |
1811 | */ | 1870 | */ |
@@ -1884,16 +1943,9 @@ out_nodev: | |||
1884 | return rc; | 1943 | return rc; |
1885 | } | 1944 | } |
1886 | 1945 | ||
1887 | module_param_call(create, fcoe_create, NULL, NULL, S_IWUSR); | ||
1888 | __MODULE_PARM_TYPE(create, "string"); | ||
1889 | MODULE_PARM_DESC(create, "Create fcoe fcoe using net device passed in."); | ||
1890 | module_param_call(destroy, fcoe_destroy, NULL, NULL, S_IWUSR); | ||
1891 | __MODULE_PARM_TYPE(destroy, "string"); | ||
1892 | MODULE_PARM_DESC(destroy, "Destroy fcoe fcoe"); | ||
1893 | |||
1894 | /** | 1946 | /** |
1895 | * fcoe_link_ok() - Check if link is ok for the fc_lport | 1947 | * fcoe_link_ok() - Check if the link is OK for a local port |
1896 | * @lp: ptr to the fc_lport | 1948 | * @lport: The local port to check link on |
1897 | * | 1949 | * |
1898 | * Any permanently-disqualifying conditions have been previously checked. | 1950 | * Any permanently-disqualifying conditions have been previously checked. |
1899 | * This also updates the speed setting, which may change with link for 100/1000. | 1951 | * This also updates the speed setting, which may change with link for 100/1000. |
@@ -1905,26 +1957,26 @@ MODULE_PARM_DESC(destroy, "Destroy fcoe fcoe"); | |||
1905 | * Returns: 0 if link is OK for use by FCoE. | 1957 | * Returns: 0 if link is OK for use by FCoE. |
1906 | * | 1958 | * |
1907 | */ | 1959 | */ |
1908 | int fcoe_link_ok(struct fc_lport *lp) | 1960 | int fcoe_link_ok(struct fc_lport *lport) |
1909 | { | 1961 | { |
1910 | struct fcoe_port *port = lport_priv(lp); | 1962 | struct fcoe_port *port = lport_priv(lport); |
1911 | struct net_device *dev = port->fcoe->netdev; | 1963 | struct net_device *netdev = port->fcoe->netdev; |
1912 | struct ethtool_cmd ecmd = { ETHTOOL_GSET }; | 1964 | struct ethtool_cmd ecmd = { ETHTOOL_GSET }; |
1913 | 1965 | ||
1914 | if ((dev->flags & IFF_UP) && netif_carrier_ok(dev) && | 1966 | if ((netdev->flags & IFF_UP) && netif_carrier_ok(netdev) && |
1915 | (!dev_ethtool_get_settings(dev, &ecmd))) { | 1967 | (!dev_ethtool_get_settings(netdev, &ecmd))) { |
1916 | lp->link_supported_speeds &= | 1968 | lport->link_supported_speeds &= |
1917 | ~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT); | 1969 | ~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT); |
1918 | if (ecmd.supported & (SUPPORTED_1000baseT_Half | | 1970 | if (ecmd.supported & (SUPPORTED_1000baseT_Half | |
1919 | SUPPORTED_1000baseT_Full)) | 1971 | SUPPORTED_1000baseT_Full)) |
1920 | lp->link_supported_speeds |= FC_PORTSPEED_1GBIT; | 1972 | lport->link_supported_speeds |= FC_PORTSPEED_1GBIT; |
1921 | if (ecmd.supported & SUPPORTED_10000baseT_Full) | 1973 | if (ecmd.supported & SUPPORTED_10000baseT_Full) |
1922 | lp->link_supported_speeds |= | 1974 | lport->link_supported_speeds |= |
1923 | FC_PORTSPEED_10GBIT; | 1975 | FC_PORTSPEED_10GBIT; |
1924 | if (ecmd.speed == SPEED_1000) | 1976 | if (ecmd.speed == SPEED_1000) |
1925 | lp->link_speed = FC_PORTSPEED_1GBIT; | 1977 | lport->link_speed = FC_PORTSPEED_1GBIT; |
1926 | if (ecmd.speed == SPEED_10000) | 1978 | if (ecmd.speed == SPEED_10000) |
1927 | lp->link_speed = FC_PORTSPEED_10GBIT; | 1979 | lport->link_speed = FC_PORTSPEED_10GBIT; |
1928 | 1980 | ||
1929 | return 0; | 1981 | return 0; |
1930 | } | 1982 | } |
@@ -1932,8 +1984,8 @@ int fcoe_link_ok(struct fc_lport *lp) | |||
1932 | } | 1984 | } |
1933 | 1985 | ||
1934 | /** | 1986 | /** |
1935 | * fcoe_percpu_clean() - Clear the pending skbs for an lport | 1987 | * fcoe_percpu_clean() - Clear all pending skbs for an local port |
1936 | * @lp: the fc_lport | 1988 | * @lport: The local port whose skbs are to be cleared |
1937 | * | 1989 | * |
1938 | * Must be called with fcoe_create_mutex held to single-thread completion. | 1990 | * Must be called with fcoe_create_mutex held to single-thread completion. |
1939 | * | 1991 | * |
@@ -1942,7 +1994,7 @@ int fcoe_link_ok(struct fc_lport *lp) | |||
1942 | * there no packets that will be handled by the lport, but also that any | 1994 | * there no packets that will be handled by the lport, but also that any |
1943 | * threads already handling packet have returned. | 1995 | * threads already handling packet have returned. |
1944 | */ | 1996 | */ |
1945 | void fcoe_percpu_clean(struct fc_lport *lp) | 1997 | void fcoe_percpu_clean(struct fc_lport *lport) |
1946 | { | 1998 | { |
1947 | struct fcoe_percpu_s *pp; | 1999 | struct fcoe_percpu_s *pp; |
1948 | struct fcoe_rcv_info *fr; | 2000 | struct fcoe_rcv_info *fr; |
@@ -1960,7 +2012,7 @@ void fcoe_percpu_clean(struct fc_lport *lp) | |||
1960 | skb = next) { | 2012 | skb = next) { |
1961 | next = skb->next; | 2013 | next = skb->next; |
1962 | fr = fcoe_dev_from_skb(skb); | 2014 | fr = fcoe_dev_from_skb(skb); |
1963 | if (fr->fr_dev == lp) { | 2015 | if (fr->fr_dev == lport) { |
1964 | __skb_unlink(skb, list); | 2016 | __skb_unlink(skb, list); |
1965 | kfree_skb(skb); | 2017 | kfree_skb(skb); |
1966 | } | 2018 | } |
@@ -1989,13 +2041,11 @@ void fcoe_percpu_clean(struct fc_lport *lp) | |||
1989 | 2041 | ||
1990 | /** | 2042 | /** |
1991 | * fcoe_clean_pending_queue() - Dequeue a skb and free it | 2043 | * fcoe_clean_pending_queue() - Dequeue a skb and free it |
1992 | * @lp: the corresponding fc_lport | 2044 | * @lport: The local port to dequeue a skb on |
1993 | * | ||
1994 | * Returns: none | ||
1995 | */ | 2045 | */ |
1996 | void fcoe_clean_pending_queue(struct fc_lport *lp) | 2046 | void fcoe_clean_pending_queue(struct fc_lport *lport) |
1997 | { | 2047 | { |
1998 | struct fcoe_port *port = lport_priv(lp); | 2048 | struct fcoe_port *port = lport_priv(lport); |
1999 | struct sk_buff *skb; | 2049 | struct sk_buff *skb; |
2000 | 2050 | ||
2001 | spin_lock_bh(&port->fcoe_pending_queue.lock); | 2051 | spin_lock_bh(&port->fcoe_pending_queue.lock); |
@@ -2008,10 +2058,10 @@ void fcoe_clean_pending_queue(struct fc_lport *lp) | |||
2008 | } | 2058 | } |
2009 | 2059 | ||
2010 | /** | 2060 | /** |
2011 | * fcoe_reset() - Resets the fcoe | 2061 | * fcoe_reset() - Reset a local port |
2012 | * @shost: shost the reset is from | 2062 | * @shost: The SCSI host associated with the local port to be reset |
2013 | * | 2063 | * |
2014 | * Returns: always 0 | 2064 | * Returns: Always 0 (return value required by FC transport template) |
2015 | */ | 2065 | */ |
2016 | int fcoe_reset(struct Scsi_Host *shost) | 2066 | int fcoe_reset(struct Scsi_Host *shost) |
2017 | { | 2067 | { |
@@ -2021,30 +2071,33 @@ int fcoe_reset(struct Scsi_Host *shost) | |||
2021 | } | 2071 | } |
2022 | 2072 | ||
2023 | /** | 2073 | /** |
2024 | * fcoe_hostlist_lookup_port() - find the corresponding lport by a given device | 2074 | * fcoe_hostlist_lookup_port() - Find the FCoE interface associated with a net device |
2025 | * @dev: this is currently ptr to net_device | 2075 | * @netdev: The net device used as a key |
2026 | * | 2076 | * |
2027 | * Returns: NULL or the located fcoe_port | 2077 | * Locking: Must be called with the RNL mutex held. |
2028 | * Locking: must be called with the RNL mutex held | 2078 | * |
2079 | * Returns: NULL or the FCoE interface | ||
2029 | */ | 2080 | */ |
2030 | static struct fcoe_interface * | 2081 | static struct fcoe_interface * |
2031 | fcoe_hostlist_lookup_port(const struct net_device *dev) | 2082 | fcoe_hostlist_lookup_port(const struct net_device *netdev) |
2032 | { | 2083 | { |
2033 | struct fcoe_interface *fcoe; | 2084 | struct fcoe_interface *fcoe; |
2034 | 2085 | ||
2035 | list_for_each_entry(fcoe, &fcoe_hostlist, list) { | 2086 | list_for_each_entry(fcoe, &fcoe_hostlist, list) { |
2036 | if (fcoe->netdev == dev) | 2087 | if (fcoe->netdev == netdev) |
2037 | return fcoe; | 2088 | return fcoe; |
2038 | } | 2089 | } |
2039 | return NULL; | 2090 | return NULL; |
2040 | } | 2091 | } |
2041 | 2092 | ||
2042 | /** | 2093 | /** |
2043 | * fcoe_hostlist_lookup() - Find the corresponding lport by netdev | 2094 | * fcoe_hostlist_lookup() - Find the local port associated with a |
2044 | * @netdev: ptr to net_device | 2095 | * given net device |
2096 | * @netdev: The netdevice used as a key | ||
2045 | * | 2097 | * |
2046 | * Returns: 0 for success | 2098 | * Locking: Must be called with the RTNL mutex held |
2047 | * Locking: must be called with the RTNL mutex held | 2099 | * |
2100 | * Returns: NULL or the local port | ||
2048 | */ | 2101 | */ |
2049 | static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev) | 2102 | static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev) |
2050 | { | 2103 | { |
@@ -2055,11 +2108,13 @@ static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev) | |||
2055 | } | 2108 | } |
2056 | 2109 | ||
2057 | /** | 2110 | /** |
2058 | * fcoe_hostlist_add() - Add a lport to lports list | 2111 | * fcoe_hostlist_add() - Add the FCoE interface identified by a local |
2059 | * @lp: ptr to the fc_lport to be added | 2112 | * port to the hostlist |
2113 | * @lport: The local port that identifies the FCoE interface to be added | ||
2060 | * | 2114 | * |
2061 | * Returns: 0 for success | ||
2062 | * Locking: must be called with the RTNL mutex held | 2115 | * Locking: must be called with the RTNL mutex held |
2116 | * | ||
2117 | * Returns: 0 for success | ||
2063 | */ | 2118 | */ |
2064 | static int fcoe_hostlist_add(const struct fc_lport *lport) | 2119 | static int fcoe_hostlist_add(const struct fc_lport *lport) |
2065 | { | 2120 | { |
@@ -2076,15 +2131,15 @@ static int fcoe_hostlist_add(const struct fc_lport *lport) | |||
2076 | } | 2131 | } |
2077 | 2132 | ||
2078 | /** | 2133 | /** |
2079 | * fcoe_init() - fcoe module loading initialization | 2134 | * fcoe_init() - Initialize fcoe.ko |
2080 | * | 2135 | * |
2081 | * Returns 0 on success, negative on failure | 2136 | * Returns: 0 on success, or a negative value on failure |
2082 | */ | 2137 | */ |
2083 | static int __init fcoe_init(void) | 2138 | static int __init fcoe_init(void) |
2084 | { | 2139 | { |
2140 | struct fcoe_percpu_s *p; | ||
2085 | unsigned int cpu; | 2141 | unsigned int cpu; |
2086 | int rc = 0; | 2142 | int rc = 0; |
2087 | struct fcoe_percpu_s *p; | ||
2088 | 2143 | ||
2089 | mutex_lock(&fcoe_config_mutex); | 2144 | mutex_lock(&fcoe_config_mutex); |
2090 | 2145 | ||
@@ -2121,15 +2176,15 @@ out_free: | |||
2121 | module_init(fcoe_init); | 2176 | module_init(fcoe_init); |
2122 | 2177 | ||
2123 | /** | 2178 | /** |
2124 | * fcoe_exit() - fcoe module unloading cleanup | 2179 | * fcoe_exit() - Clean up fcoe.ko |
2125 | * | 2180 | * |
2126 | * Returns 0 on success, negative on failure | 2181 | * Returns: 0 on success or a negative value on failure |
2127 | */ | 2182 | */ |
2128 | static void __exit fcoe_exit(void) | 2183 | static void __exit fcoe_exit(void) |
2129 | { | 2184 | { |
2130 | unsigned int cpu; | ||
2131 | struct fcoe_interface *fcoe, *tmp; | 2185 | struct fcoe_interface *fcoe, *tmp; |
2132 | struct fcoe_port *port; | 2186 | struct fcoe_port *port; |
2187 | unsigned int cpu; | ||
2133 | 2188 | ||
2134 | mutex_lock(&fcoe_config_mutex); | 2189 | mutex_lock(&fcoe_config_mutex); |
2135 | 2190 | ||
@@ -2230,10 +2285,12 @@ static void fcoe_logo_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
2230 | * | 2285 | * |
2231 | * Most of the work here is just handed off to the libfc routine. | 2286 | * Most of the work here is just handed off to the libfc routine. |
2232 | */ | 2287 | */ |
2233 | static struct fc_seq *fcoe_elsct_send(struct fc_lport *lport, | 2288 | static struct fc_seq *fcoe_elsct_send(struct fc_lport *lport, u32 did, |
2234 | u32 did, struct fc_frame *fp, unsigned int op, | 2289 | struct fc_frame *fp, unsigned int op, |
2235 | void (*resp)(struct fc_seq *, struct fc_frame *, void *), | 2290 | void (*resp)(struct fc_seq *, |
2236 | void *arg, u32 timeout) | 2291 | struct fc_frame *, |
2292 | void *), | ||
2293 | void *arg, u32 timeout) | ||
2237 | { | 2294 | { |
2238 | struct fcoe_port *port = lport_priv(lport); | 2295 | struct fcoe_port *port = lport_priv(lport); |
2239 | struct fcoe_interface *fcoe = port->fcoe; | 2296 | struct fcoe_interface *fcoe = port->fcoe; |
@@ -2362,4 +2419,3 @@ static void fcoe_set_vport_symbolic_name(struct fc_vport *vport) | |||
2362 | lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RSPN_ID, | 2419 | lport->tt.elsct_send(lport, FC_FID_DIR_SERV, fp, FC_NS_RSPN_ID, |
2363 | NULL, NULL, lport->e_d_tov); | 2420 | NULL, NULL, lport->e_d_tov); |
2364 | } | 2421 | } |
2365 | |||
diff --git a/drivers/scsi/fcoe/fcoe.h b/drivers/scsi/fcoe/fcoe.h index 99dfa7c2aeaa..c69b2c56c2d1 100644 --- a/drivers/scsi/fcoe/fcoe.h +++ b/drivers/scsi/fcoe/fcoe.h | |||
@@ -50,7 +50,7 @@ unsigned int fcoe_debug_logging; | |||
50 | module_param_named(debug_logging, fcoe_debug_logging, int, S_IRUGO|S_IWUSR); | 50 | module_param_named(debug_logging, fcoe_debug_logging, int, S_IRUGO|S_IWUSR); |
51 | MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels"); | 51 | MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels"); |
52 | 52 | ||
53 | #define FCOE_LOGGING 0x01 /* General logging, not categorized */ | 53 | #define FCOE_LOGGING 0x01 /* General logging, not categorized */ |
54 | #define FCOE_NETDEV_LOGGING 0x02 /* Netdevice logging */ | 54 | #define FCOE_NETDEV_LOGGING 0x02 /* Netdevice logging */ |
55 | 55 | ||
56 | #define FCOE_CHECK_LOGGING(LEVEL, CMD) \ | 56 | #define FCOE_CHECK_LOGGING(LEVEL, CMD) \ |
@@ -70,8 +70,13 @@ do { \ | |||
70 | printk(KERN_INFO "fcoe: %s: " fmt, \ | 70 | printk(KERN_INFO "fcoe: %s: " fmt, \ |
71 | netdev->name, ##args);) | 71 | netdev->name, ##args);) |
72 | 72 | ||
73 | /* | 73 | /** |
74 | * this percpu struct for fcoe | 74 | * struct fcoe_percpu_s - The per-CPU context for FCoE receive threads |
75 | * @thread: The thread context | ||
76 | * @fcoe_rx_list: The queue of pending packets to process | ||
77 | * @page: The memory page for calculating frame trailer CRCs | ||
78 | * @crc_eof_offset: The offset into the CRC page pointing to available | ||
79 | * memory for a new trailer | ||
75 | */ | 80 | */ |
76 | struct fcoe_percpu_s { | 81 | struct fcoe_percpu_s { |
77 | struct task_struct *thread; | 82 | struct task_struct *thread; |
@@ -80,38 +85,62 @@ struct fcoe_percpu_s { | |||
80 | int crc_eof_offset; | 85 | int crc_eof_offset; |
81 | }; | 86 | }; |
82 | 87 | ||
83 | /* | 88 | /** |
84 | * an FCoE interface, 1:1 with netdev | 89 | * struct fcoe_interface - A FCoE interface |
90 | * @list: Handle for a list of FCoE interfaces | ||
91 | * @netdev: The associated net device | ||
92 | * @fcoe_packet_type: FCoE packet type | ||
93 | * @fip_packet_type: FIP packet type | ||
94 | * @ctlr: The FCoE controller (for FIP) | ||
95 | * @oem: The offload exchange manager for all local port | ||
96 | * instances associated with this port | ||
97 | * @kref: The kernel reference | ||
98 | * | ||
99 | * This structure is 1:1 with a net devive. | ||
85 | */ | 100 | */ |
86 | struct fcoe_interface { | 101 | struct fcoe_interface { |
87 | struct list_head list; | 102 | struct list_head list; |
88 | struct net_device *netdev; | 103 | struct net_device *netdev; |
89 | struct packet_type fcoe_packet_type; | 104 | struct packet_type fcoe_packet_type; |
90 | struct packet_type fip_packet_type; | 105 | struct packet_type fip_packet_type; |
91 | struct fcoe_ctlr ctlr; | 106 | struct fcoe_ctlr ctlr; |
92 | struct fc_exch_mgr *oem; /* offload exchange manager */ | 107 | struct fc_exch_mgr *oem; |
93 | struct kref kref; | 108 | struct kref kref; |
94 | }; | 109 | }; |
95 | 110 | ||
96 | /* | 111 | /** |
97 | * the FCoE private structure that's allocated along with the | 112 | * struct fcoe_port - The FCoE private structure |
98 | * Scsi_Host and libfc fc_lport structures | 113 | * @fcoe: The associated fcoe interface |
114 | * @lport: The associated local port | ||
115 | * @fcoe_pending_queue: The pending Rx queue of skbs | ||
116 | * @fcoe_pending_queue_active: Indicates if the pending queue is active | ||
117 | * @timer: The queue timer | ||
118 | * @destroy_work: Handle for work context | ||
119 | * (to prevent RTNL deadlocks) | ||
120 | * @data_srt_addr: Source address for data | ||
121 | * | ||
122 | * An instance of this structure is to be allocated along with the | ||
123 | * Scsi_Host and libfc fc_lport structures. | ||
99 | */ | 124 | */ |
100 | struct fcoe_port { | 125 | struct fcoe_port { |
101 | struct fcoe_interface *fcoe; | 126 | struct fcoe_interface *fcoe; |
102 | struct fc_lport *lport; | 127 | struct fc_lport *lport; |
103 | struct sk_buff_head fcoe_pending_queue; | 128 | struct sk_buff_head fcoe_pending_queue; |
104 | u8 fcoe_pending_queue_active; | 129 | u8 fcoe_pending_queue_active; |
105 | struct timer_list timer; /* queue timer */ | 130 | struct timer_list timer; |
106 | struct work_struct destroy_work; /* to prevent rtnl deadlocks */ | 131 | struct work_struct destroy_work; |
107 | u8 data_src_addr[ETH_ALEN]; | 132 | u8 data_src_addr[ETH_ALEN]; |
108 | }; | 133 | }; |
109 | 134 | ||
110 | #define fcoe_from_ctlr(fip) container_of(fip, struct fcoe_interface, ctlr) | 135 | #define fcoe_from_ctlr(fip) container_of(fip, struct fcoe_interface, ctlr) |
111 | 136 | ||
112 | static inline struct net_device *fcoe_netdev(const struct fc_lport *lp) | 137 | /** |
138 | * fcoe_netdev() - Return the net device associated with a local port | ||
139 | * @lport: The local port to get the net device from | ||
140 | */ | ||
141 | static inline struct net_device *fcoe_netdev(const struct fc_lport *lport) | ||
113 | { | 142 | { |
114 | return ((struct fcoe_port *)lport_priv(lp))->fcoe->netdev; | 143 | return ((struct fcoe_port *)lport_priv(lport))->fcoe->netdev; |
115 | } | 144 | } |
116 | 145 | ||
117 | #endif /* _FCOE_H_ */ | 146 | #endif /* _FCOE_H_ */ |