1 /* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */
4 * Ethernet portion of AoE driver
8 #include <linux/hdreg.h>
9 #include <linux/blkdev.h>
10 #include <linux/netdevice.h>
11 #include <linux/moduleparam.h>
12 #include <net/net_namespace.h>
13 #include <asm/unaligned.h>
18 static char *aoe_errlist
[] =
21 "unrecognized command code",
22 "bad argument parameter",
24 "config string present",
32 static char aoe_iflist
[IFLISTSZ
];
33 module_param_string(aoe_iflist
, aoe_iflist
, IFLISTSZ
, 0600);
34 MODULE_PARM_DESC(aoe_iflist
, "aoe_iflist=\"dev1 [dev2 ...]\"");
37 static int __init
aoe_iflist_setup(char *str
)
39 strncpy(aoe_iflist
, str
, IFLISTSZ
);
40 aoe_iflist
[IFLISTSZ
- 1] = '\0';
44 __setup("aoe_iflist=", aoe_iflist_setup
);
48 is_aoe_netif(struct net_device
*ifp
)
53 if (aoe_iflist
[0] == '\0')
56 p
= aoe_iflist
+ strspn(aoe_iflist
, WHITESPACE
);
57 for (; *p
; p
= q
+ strspn(q
, WHITESPACE
)) {
58 q
= p
+ strcspn(p
, WHITESPACE
);
62 len
= strlen(p
); /* last token in aoe_iflist */
64 if (strlen(ifp
->name
) == len
&& !strncmp(ifp
->name
, p
, len
))
74 set_aoe_iflist(const char __user
*user_str
, size_t size
)
79 if (copy_from_user(aoe_iflist
, user_str
, size
)) {
80 printk(KERN_INFO
"aoe: copy from user failed\n");
83 aoe_iflist
[size
] = 0x00;
88 aoenet_xmit(struct sk_buff_head
*queue
)
90 struct sk_buff
*skb
, *tmp
;
92 skb_queue_walk_safe(queue
, skb
, tmp
) {
93 __skb_unlink(skb
, queue
);
99 * (1) len doesn't include the header by default. I want this.
102 aoenet_rcv(struct sk_buff
*skb
, struct net_device
*ifp
, struct packet_type
*pt
, struct net_device
*orig_dev
)
107 if (dev_net(ifp
) != &init_net
)
110 skb
= skb_share_check(skb
, GFP_ATOMIC
);
113 if (skb_linearize(skb
))
115 if (!is_aoe_netif(ifp
))
117 skb_push(skb
, ETH_HLEN
); /* (1) */
119 h
= (struct aoe_hdr
*) skb_mac_header(skb
);
120 n
= get_unaligned_be32(&h
->tag
);
121 if ((h
->verfl
& AOEFL_RSP
) == 0 || (n
& 1<<31))
124 if (h
->verfl
& AOEFL_ERR
) {
130 "%s%d.%d@%s; ecode=%d '%s'\n",
131 "aoe: error packet from ",
132 get_unaligned_be16(&h
->major
),
133 h
->minor
, skb
->dev
->name
,
134 h
->err
, aoe_errlist
[n
]);
146 if (h
->cmd
>= AOECMD_VEND_MIN
)
147 break; /* don't complain about vendor commands */
148 printk(KERN_INFO
"aoe: unknown cmd %d\n", h
->cmd
);
155 static struct packet_type aoe_pt __read_mostly
= {
156 .type
= __constant_htons(ETH_P_AOE
),
163 dev_add_pack(&aoe_pt
);
170 dev_remove_pack(&aoe_pt
);