20 #include <linux/types.h>
21 #include <linux/module.h>
22 #include <linux/kernel.h>
23 #include <linux/list.h>
24 #include <linux/netdevice.h>
25 #include <linux/errno.h>
35 static int fcoe_transport_create(
const char *,
struct kernel_param *);
36 static int fcoe_transport_destroy(
const char *,
struct kernel_param *);
40 static int fcoe_transport_enable(
const char *,
struct kernel_param *);
41 static int fcoe_transport_disable(
const char *,
struct kernel_param *);
42 static int libfcoe_device_notification(
struct notifier_block *notifier,
66 MODULE_PARM_DESC(create_vn2vn,
" Creates a VN_node to VN_node FCoE instance "
67 "on an Ethernet interface");
83 .notifier_call = libfcoe_device_notification,
100 memset(lesb, 0,
sizeof(*lesb));
119 u64_to_wwn(wwn, wwpn);
120 snprintf(buf, len,
"%02x%02x%02x%02x%02x%02x%02x%02x",
121 wwpn[0], wwpn[1], wwpn[2], wwpn[3],
122 wwpn[4], wwpn[5], wwpn[6], wwpn[7]);
138 struct fc_lport *n_port = shost_priv(shost);
149 "base port WWPN\n", buf);
158 "already exists\n", buf);
181 if (ops->ndo_fcoe_get_wwn)
182 return ops->ndo_fcoe_get_wwn(netdev, wwn, type);
204 crc =
crc32(~0, skb->
data, skb_headlen(skb));
206 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
207 frag = &skb_shinfo(skb)->frags[
i];
209 len = skb_frag_size(frag);
369 skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags, page,
425 list_add(&ft->list, &fcoe_transports);
462 "remove its netdev mapping for %s\n",
486 i = j =
sprintf(buffer,
"Attached FCoE transports:");
499 static int __init fcoe_transport_init(
void)
505 static int fcoe_transport_exit(
void)
534 list_add(&nm->
list, &fcoe_netdevs);
540 static void fcoe_del_netdev_mapping(
struct net_device *netdev)
546 if (nm->
netdev == netdev) {
573 if (netdev == nm->
netdev) {
590 static struct net_device *fcoe_if_to_netdev(
const char *buffer)
597 cp = ifname +
strlen(ifname);
598 while (--cp >= ifname && *cp ==
'\n')
615 static int libfcoe_device_notification(
struct notifier_block *notifier,
624 fcoe_del_netdev_mapping(netdev);
641 static int fcoe_transport_create(
const char *buffer,
struct kernel_param *kp)
650 netdev = fcoe_if_to_netdev(buffer);
656 ft = fcoe_netdev_map_lookup(netdev);
659 "FCoE instance on %s.\n",
665 ft = fcoe_transport_lookup(netdev);
672 rc = fcoe_add_netdev_mapping(netdev, ft);
675 "for FCoE transport %s for %s.\n",
683 fcoe_del_netdev_mapping(netdev);
686 ft->
name, (rc) ?
"failed" :
"succeeded",
706 static int fcoe_transport_destroy(
const char *buffer,
struct kernel_param *kp)
714 netdev = fcoe_if_to_netdev(buffer);
720 ft = fcoe_netdev_map_lookup(netdev);
729 fcoe_del_netdev_mapping(netdev);
731 ft->
name, (rc) ?
"failed" :
"succeeded",
750 static int fcoe_transport_disable(
const char *buffer,
struct kernel_param *kp)
758 netdev = fcoe_if_to_netdev(buffer);
762 ft = fcoe_netdev_map_lookup(netdev);
774 return restart_syscall();
788 static int fcoe_transport_enable(
const char *buffer,
struct kernel_param *kp)
796 netdev = fcoe_if_to_netdev(buffer);
800 ft = fcoe_netdev_map_lookup(netdev);
816 static int __init libfcoe_init(
void)
820 rc = fcoe_transport_init();
826 fcoe_transport_exit();
835 static void __exit libfcoe_exit(
void)
838 fcoe_transport_exit();